nixpkgs/pkgs/by-name
2023-09-11 16:16:33 -04:00
..
ai/airscan airscan: init at 0.3 2023-09-10 12:54:15 +02:00
as/asciiquarium-transparent asciiquarium-transparent: init at unstable-2023-02-19 (#253439) 2023-09-05 23:20:06 +02:00
bo/bochs bochs: move to by-name hierarchy 2023-09-10 12:43:51 +00:00
cd/cdwe cdwe: init at 0.3.0 2023-09-08 18:35:51 -04:00
en/engage engage: 0.1.2 -> 0.1.3 2023-09-10 15:37:05 -07:00
ga gash-utils: init at 0.2.0 2023-09-05 19:40:05 +02:00
gh/ghunt ghunt: init at 2.0.1 2023-09-10 17:56:56 +02:00
he/hello
if/ifrextractor-rs ifrextractor-rs: init at 1.5.1 2023-09-08 16:39:00 +02:00
ir/ironbar ironbar: init at 0.13.0 2023-09-09 20:48:37 +02:00
ji/jinja2-cli jinja2-cli: init at 0.8.2 2023-09-08 21:10:04 -04:00
li/liana liana: init at 2.0 2023-09-09 11:05:34 +02:00
pa/passes passes: init at 0.8 2023-09-09 20:30:01 +02:00
ri/ripsecrets ripsecrets: 0.1.6 -> 0.1.7 2023-09-11 16:16:33 -04:00
ru/rusti-cal rusti-cal: init at 1.1.0 2023-09-08 16:27:47 +02:00
sc/screentest screentest: init at unstable-2021-05-10 2023-09-07 23:00:37 +02:00
ss/sssnake sssnake: init at 0.3.2 (#253441) 2023-09-05 22:21:56 +02:00
tc/tcsh tcsh: migrate to by-name 2023-09-10 01:35:11 +00:00
th/the-legend-of-edgar the-legend-of-edgar: migrate to by-name 2023-09-11 18:40:42 +00:00
up/upiano upiano: init at 0.1.2 2023-09-08 22:12:29 -04:00
wa/wayland-logout wayland-logout: init at 1.4 2023-09-05 20:08:12 +02:00
wi/windowmaker windowmaker: 0.95.9 -> 0.96.0 2023-09-10 12:14:55 +00:00
wo/wonderdraft wonderdraft: init at 1.1.7.3 2023-09-09 21:15:07 +02:00
zc/zcfan zcfan: init at 1.2.1 2023-09-08 19:43:02 +02:00
zx/zxpy zxpy: init at 1.6.3 2023-09-08 23:27:41 -04:00
README.md pkgs/by-name: Fix minor mistake in README 2023-09-06 19:29:43 +02:00

Name-based package directories

The structure of this directory maps almost directly to top-level package attributes. This is the recommended way to add new top-level packages to Nixpkgs when possible.

Example

The top-level package pkgs.some-package may be declared by setting up this file structure:

pkgs
└── by-name
   ├── so
   ┊  ├── some-package
      ┊  └── package.nix

Where some-package is the package name and so is the lowercased 2-letter prefix of the package name.

The package.nix may look like this:

# A function taking an attribute set as an argument
{
  # Get access to top-level attributes for use as dependencies
  lib,
  stdenv,
  libbar,

  # Make this derivation configurable using `.override { enableBar = true }`
  enableBar ? false,
}:

# The return value must be a derivation
stdenv.mkDerivation {
  # ...
  buildInputs =
    lib.optional enableBar libbar;
}

You can also split up the package definition into more files in the same directory if necessary.

Once defined, the package can be built from the Nixpkgs root directory using:

nix-build -A some-package

See the general package conventions for more information on package definitions.

Changing implicit attribute defaults

The above expression is called using these arguments by default:

{
  lib = pkgs.lib;
  stdenv = pkgs.stdenv;
  libbar = pkgs.libbar;
}

But the package might need pkgs.libbar_2 instead. While the function could be changed to take libbar_2 directly as an argument, this would change the .override interface, breaking code like .override { libbar = ...; }. So instead it is preferable to use the same generic parameter name libbar and override its value in pkgs/top-level/all-packages.nix:

libfoo = callPackage ../by-name/so/some-package/package.nix {
  libbar = libbar_2;
};

Limitations

There's 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 use the category hierarchy for such attributes.

  • 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 on the pkgs/by-name structure. This is done using the nixpkgs-check-by-name tool. The version of this tool used is the one that corresponds to the NixOS channel of the PR base branch. See here for details.

The tool can be run locally using

nix-build -A tests.nixpkgs-check-by-name
result/bin/nixpkgs-check-by-name .