Packages outside nixpkgs
Some programs installed by the framework do not exist in
nixpkgs 🡕. Their build recipes live in
dnf/pkgs/, and are exposed to all hosts like any other package, under
pkgs.<name>.
Where to put what
Section titled “Where to put what”Three locations exist for a package that is out of the ordinary, with three different intents.
| Location | Purpose | Lifetime |
|---|---|---|
dnf/pkgs/ | Not in nixpkgs, installed by hosts or users. | Until published in nixpkgs. |
dnf/lib/overlays/ | Patch on an existing nixpkgs package (broken build, pending PR). | Temporary, removed as soon as the upstream fix lands. |
inputs of dnf/flake.nix | What the framework machinery needs (dnf-generator, colmena). | Permanent. |
Directory structure
Section titled “Directory structure”dnf/pkgs/├── default.nix <-- package set, discovered from subdirectories├── overlay.nix <-- the same set as an overlay -> pkgs.<name>└── <name>/package.nix <-- the derivationOne folder = one package. default.nix scans subdirectories, so there is
no registry to maintain. The overlay, on the other hand, is applied once
and for all by dnf/lib/mk-configuration.nix, on every host.
Adding a package
Section titled “Adding a package”-
Create
dnf/pkgs/<name>/package.nixusing the classiccallPackageform, with a completemetablock (description,homepage,license,mainProgram,platforms). Pin the stable version, not a branch. -
git addthe folder: flakes ignore untracked files. -
Build once to freeze the hashes, which Nix displays in its error message :
Fenêtre de terminal nix build .#<name> -
just cleanthen commit.
Nothing else to wire up. The package is now usable in any NixOS module or Home Manager module, just like a nixpkgs package :
(lib.mkIf cfg.enableEssentials rename-simple)Updating a package
Section titled “Updating a package”Run it in dnf/ or at the root of a co-development project : a dnf/
linked to the Nix store is read-only.
just pkg-update <nom>nix-update 🡕 looks up the latest release
published upstream, then rewrites the version and the hashes in package.nix.
Then check the upstream changelog, rebuild, and commit.
Publishing to nixpkgs
Section titled “Publishing to nixpkgs”The end goal, for every package of general interest :
- Move the folder into a nixpkgs clone, under the two-letter shard of the
name (
pkgs/by-name/re/rename-simple/). - Add the
maintainersentry, open the pull request. - Once the PR is merged and made it into
nixos-unstable, remove the folder fromdnf/pkgs/.
pkgs.<name> keeps resolving, this time from nixpkgs: no module needs to be
updated.