{"id":14967838,"url":"https://github.com/nixos/nixpkgs-vet","last_synced_at":"2025-10-19T09:31:47.808Z","repository":{"id":228121749,"uuid":"772919507","full_name":"NixOS/nixpkgs-vet","owner":"NixOS","description":"Tool to check Nixpkgs' pkgs/by-name directory","archived":false,"fork":false,"pushed_at":"2024-08-29T14:47:05.000Z","size":514,"stargazers_count":12,"open_issues_count":14,"forks_count":4,"subscribers_count":7,"default_branch":"main","last_synced_at":"2024-08-29T16:27:35.662Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/NixOS.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"open_collective":"nixos"}},"created_at":"2024-03-16T08:35:08.000Z","updated_at":"2024-08-29T14:47:10.000Z","dependencies_parsed_at":"2024-08-29T16:37:49.219Z","dependency_job_id":null,"html_url":"https://github.com/NixOS/nixpkgs-vet","commit_stats":{"total_commits":189,"total_committers":9,"mean_commits":21.0,"dds":0.2063492063492064,"last_synced_commit":"2d9b9d2f320576dc953177e8e1fa91951075d411"},"previous_names":["nixos/nixpkgs-check-by-name","nixos/nixpkgs-vet"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NixOS%2Fnixpkgs-vet","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NixOS%2Fnixpkgs-vet/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NixOS%2Fnixpkgs-vet/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NixOS%2Fnixpkgs-vet/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/NixOS","download_url":"https://codeload.github.com/NixOS/nixpkgs-vet/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":219869246,"owners_count":16555571,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-09-24T13:38:41.721Z","updated_at":"2025-10-19T09:31:42.169Z","avatar_url":"https://github.com/NixOS.png","language":"Rust","funding_links":["https://opencollective.com/nixos"],"categories":[],"sub_categories":[],"readme":"# Nixpkgs vet (check) tool\n\nThis repository implements a program  which checks Nixpkgs for many sorts of defects, both major and minor. It's named `nixpkgs-vet`, since it '[vets](https://en.wiktionary.org/wiki/vet#Verb)' contributions to Nixpkgs.\n\nIt implements all checks for [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).\n\nSee [`CONTRIBUTING.md`](./CONTRIBUTING.md) for contributor documentation. Below is the user documentation.\n\nCurrently the only intended user for this program is [Nixpkgs](https://github.com/NixOS/nixpkgs).\nExpect that the interface may be changed in breaking ways as long as Nixpkgs is adjusted to deal with it.\nSee [the `pkgs/by-name` Readme](https://github.com/NixOS/nixpkgs/blob/master/pkgs/by-name/README.md#validation) for how it's used in Nixpkgs.\n\n## Nix derivations\n\nThe source code contains a `default.nix` file, which defines a Nix function.\n\nThe function takes an attribute set with at least these attributes as its argument:\n- `system` (String, defaults to [`builtins.currentSystem`](https://nix.dev/manual/nix/stable/language/builtin-constants#builtins-currentSystem)):\n  The [`system`](https://nixos.org/manual/nix/stable/language/derivations#attr-system)\n  to build the resulting derivation with.\n\nThe function returns an attribute set with at least these attributes:\n- `build` ([Package attribute set](https://nixos.org/manual/nix/stable/glossary#package-attribute-set)):\n  A derivation that can be built with the given `system`.\n\nThere is no guarantee that the derivation succeeds on systems that don't have [prebuilt store paths](#prebuilt-store-paths),\nbut it can be attempted with\n\n```bash\nnix-build https://github.com/NixOS/nixpkgs-vet/tarball/master -A build\n```\n\n## Prebuilt store paths\n\nThe [GitHub releases](https://github.com/NixOS/nixpkgs-vet/releases)\ncontain a [gzip](https://en.wikipedia.org/wiki/Gzip)-compressed\n[Nix Archive](https://nixos.org/manual/nix/stable/command-ref/nix-store/export.html)\nof the [build closure](https://nixos.org/manual/nix/stable/glossary#gloss-closure)\nof the [Nix derivation](#nix-derivations) with `x86_64-linux` as the `system`.\n\nThis release artifact is named `x86_64-linux.nar.gz`\nand can be imported into a local Nix store using:\n\n```bash\nstorePath=$(gzip -cd x86_64-linux.nar.gz | nix-store --import | tail -1)\n# To prevent it from being garbage-collected\nnix-store --realise \"$storePath\" --add-root result\n```\n\nCompared to building the [Nix derivations](#nix-derivations),\nthis has the benefit that no Nix evaluation needs to take place\nand is therefore much faster and less storage intensive.\n\n## Binary interface\n\nThe store path acquired from the above methods contains\na `system`-specific binary under `$storePath/bin/nixpkgs-vet`.\n\nThe public interface of this binary is printed by calling\n```bash\nresult/bin/nixpkgs-vet --help\n```\n\n## Validity checks\n\nThe following checks are performed when calling the binary:\n\n### File structure checks\n- `pkgs/by-name` must only contain subdirectories of the form `${shard}/${name}`, called _package directories_.\n- The `name`'s of package directories must be unique when lowercased.\n- `name` is a string only consisting of the ASCII characters `a-z`, `A-Z`, `0-9`, `-` or `_`.\n- `shard` is the lowercased first two letters of `name`, expressed in Nix: `shard = toLower (substring 0 2 name)`.\n- Each package directory must contain a `package.nix` file and may contain arbitrary other files.\n\n### Nix parser checks\n- Each package directory must not refer to files outside itself using symlinks or Nix path expressions.\n\n### Nix evaluation checks\n\nEvaluate Nixpkgs with `system` set to `x86_64-linux` and check that:\n- For each package directory, the `pkgs.${name}` attribute must be defined as `callPackage pkgs/by-name/${shard}/${name}/package.nix args` for some `args`.\n- For each package directory, `pkgs.lib.isDerivation pkgs.${name}` must be `true`.\n\n### Ratchet checks\n\nFurthermore, this tool implements certain [ratchet](https://qntm.org/ratchet) checks.\nThis allows gradually phasing out deprecated patterns without breaking the base branch or having to migrate it all at once.\nIt works by not allowing new instances of the pattern to be introduced, but allowing already existing instances.\nThe existing instances are coming from `\u003cBASE_NIXPKGS\u003e`, which is then checked against `\u003cNIXPKGS\u003e` for new instances.\nRatchets should be removed eventually once the pattern is not used anymore.\n\nThe current ratchets are:\n\n- New manual definitions of `pkgs.${name}` (e.g. in `pkgs/top-level/all-packages.nix`) with `args = { }`\n  (see [nix evaluation checks](#nix-evaluation-checks)) must not be introduced.\n- New top-level packages defined using `pkgs.callPackage` must be defined with a package directory.\n  - Once a top-level package uses `pkgs/by-name`, it also can't be moved back out of it.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnixos%2Fnixpkgs-vet","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnixos%2Fnixpkgs-vet","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnixos%2Fnixpkgs-vet/lists"}