Home Explore Blog Models CI



nixpkgs

2nd chunk of `pkgs/by-name/README.md`
f6ccbac6820945b25cc84f1bd35a635bc66271d6d9c876cd000000010000091d
though it is expected to still take some time to get done.
If you're interested in helping out with this effort,
please see [this ticket](https://github.com/NixOS/nixpkgs-vet/issues/56).

Since [only PRs to packages in `pkgs/by-name` can be automatically merged](../../CONTRIBUTING.md#how-to-merge-pull-requests-yourself),
if package maintainers would like to use this feature, they are welcome to migrate their packages to `pkgs/by-name`.
To lessen PR traffic, they're encouraged to also perform some more general maintenance on the package in the same PR,
though this is not required and must not be expected.

Note that `callPackage` definitions in `all-packages.nix` with custom arguments should not be removed.
That is a backwards-incompatible change because it changes the `.override` interface.
Such packages may still be moved to `pkgs/by-name` however, in order to avoid the slightly superficial choice of directory / category in which the `default.nix` file was placed, but please keep the definition in `all-packages.nix` using `callPackage`.
See also [changing implicit attribute defaults](#changing-implicit-attribute-defaults).

Definitions like the following however, _can_ be transitioned:

```nix
# all-packages.nix
{
  fooWithBaz = foo.override { bar = baz; };
}
```

```nix
# turned into pkgs/by-name/fo/fooWithBaz/package.nix with:
{ foo, baz }:

foo.override { bar = baz; }
```

## Limitations

There are some limitations as to which packages can be defined using this structure:

- Only packages defined using `pkgs.callPackage`.
  This excludes packages defined using `pkgs.python3Packages.callPackage ...`.

  Instead:
  - Either change the package definition to work with `pkgs.callPackage`.
  - Or use the [category hierarchy](../README.md#category-hierarchy).

- Only top-level packages.
  This excludes packages for other package sets like `pkgs.pythonPackages.*`.

  Refer to the definition and documentation of the respective package set to figure out how such packages can be declared.

## Validation

CI performs [certain checks](https://github.com/NixOS/nixpkgs-vet?tab=readme-ov-file#validity-checks) on the `pkgs/by-name` structure.
This is done using the [`nixpkgs-vet` tool](https://github.com/NixOS/nixpkgs-vet).

You can locally emulate the CI check using

```
$ ./ci/nixpkgs-vet.sh master
```

Title: Nixpkgs `pkgs/by-name` Migration Guidelines, Limitations, and Validation
Summary
This section details the manual migration guidelines for moving packages to the `pkgs/by-name` directory in Nixpkgs, which allows for automatic PR merging. It stresses that `callPackage` definitions with custom arguments in `all-packages.nix` must be preserved to maintain `.override` interface compatibility, even if the package's `package.nix` file moves. However, simple override definitions in `all-packages.nix` *can* be transitioned to the new structure. Key limitations of `pkgs/by-name` include only supporting `pkgs.callPackage` (excluding, for example, `pkgs.python3Packages.callPackage`) and only top-level packages. Finally, it outlines that CI performs validity checks on `pkgs/by-name` using the `nixpkgs-vet` tool, which can also be run locally.