|
1 | 1 | # Nixpkgs pkgs/by-name checker |
2 | 2 |
|
3 | | -This directory implements a program to check the [validity](#validity-checks) of the [`pkgs/by-name` Nixpkgs directory](https://github.com/NixOS/nixpkgs/tree/master/pkgs/by-name). |
4 | | -This is part of the implementation of [RFC 140](https://github.com/NixOS/rfcs/pull/140). |
| 3 | +This repository implements a program to check [Nixpkgs' `pkgs/by-name` directory](https://github.com/NixOS/nixpkgs/tree/master/pkgs/by-name) as part of [RFC 140](https://github.com/NixOS/rfcs/pull/140). |
5 | 4 |
|
6 | 5 | See [`CONTRIBUTING.md`](./CONTRIBUTING.md) for contributor documentation. |
7 | 6 | Below is the user documentation. |
8 | 7 |
|
9 | | -To see how it is used in Nixpkgs, see the [`check-by-name.yml` workflow](https://github.com/NixOS/nixpkgs/blob/master/.github/workflows/check-by-name.yml). |
| 8 | +Currently the only intended user for this program is [Nixpkgs](https://github.com/NixOS/nixpkgs). |
| 9 | +So the interface may be changed in breaking ways as long as Nixpkgs is adjusted to deal with it. |
| 10 | +See [the `pkgs/by-name` Readme](https://github.com/NixOS/nixpkgs/blob/master/pkgs/by-name/README.md#validation) |
| 11 | +for how it's used in Nixpkgs. |
10 | 12 |
|
| 13 | +## Nix derivations |
11 | 14 |
|
12 | | -## Interface |
| 15 | +The source code contains a `default.nix` file, which defines a Nix function. |
13 | 16 |
|
14 | | -The interface of the tool is shown with `--help`: |
| 17 | +The function takes an attribute set with at least these attributes as its argument: |
| 18 | +- `system` (String, defaults to [`builtins.currentSystem`](https://nixos.org/manual/nix/stable/language/builtin-constants.html#builtins-currentSystem)): |
| 19 | + The [`system`](https://nixos.org/manual/nix/stable/language/derivations#attr-system) |
| 20 | + to build the resulting derivation with. |
| 21 | + |
| 22 | +The function returns an attribute set with at least these attributes: |
| 23 | +- `build` ([Package attribute set](https://nixos.org/manual/nix/stable/glossary#package-attribute-set)): |
| 24 | + A derivation that can be built with the given `system`. |
| 25 | + |
| 26 | +There is no guarantee that the derivation succeeds on systems that don't have [prebuilt store paths](#prebuilt-store-paths), |
| 27 | +but it can be attempted with |
| 28 | + |
| 29 | +```bash |
| 30 | +nix-build https://github.com/NixOS/nixpkgs-check-by-name/tarball/master -A build |
15 | 31 | ``` |
16 | | -cargo run -- --help |
| 32 | + |
| 33 | +## Prebuilt store paths |
| 34 | + |
| 35 | +The [GitHub releases](https://github.com/NixOS/nixpkgs-check-by-name/releases) |
| 36 | +contain a [gzip](https://www.gnu.org/software/gzip/)-compressed |
| 37 | +[Nix Archive](https://nixos.org/manual/nix/stable/command-ref/nix-store/export.html) |
| 38 | +of the [build closure](https://nixos.org/manual/nix/stable/glossary#gloss-closure) |
| 39 | +of the [Nix derivation](#nix-derivation) with `x86_64-linux` as the `system`. |
| 40 | + |
| 41 | +This release artifact is named `x86_64-linux.nar.gz` |
| 42 | +and can be imported into a local Nix store using: |
| 43 | + |
| 44 | +```bash |
| 45 | +storePath=$(gzip -cd x86_64-linux.nar.gz | nix-store --import | tail -1) |
| 46 | +# To prevent it from being garbage-collected |
| 47 | +nix-store --realise "$storePath" --add-root result |
17 | 48 | ``` |
18 | 49 |
|
19 | | -The interface may be changed over time only if the CI workflow making use of it is adjusted to deal with the change appropriately. |
| 50 | +Compared to building the [Nix derivations](#nix-derivations), |
| 51 | +this has the benefit that no Nix evaluation needs to take place |
| 52 | +and is therefore much faster and less storage intensive. |
| 53 | + |
| 54 | +## Binary interface |
| 55 | + |
| 56 | +The store path acquired from the above methods contains |
| 57 | +a `system`-specific binary under `$storePath/bin/nixpkgs-check-by-name`. |
| 58 | + |
| 59 | +The public interface of this binary is printed by calling |
| 60 | +```bash |
| 61 | +result/bin/nixpkgs-check-by-name --help |
| 62 | +``` |
20 | 63 |
|
21 | 64 | ## Validity checks |
22 | 65 |
|
23 | | -These checks are performed by this tool: |
| 66 | +The following checks are performed when calling the binary: |
24 | 67 |
|
25 | 68 | ### File structure checks |
26 | 69 | - `pkgs/by-name` must only contain subdirectories of the form `${shard}/${name}`, called _package directories_. |
|
0 commit comments