A CLI that shows which nixpkgs branches and channels a merged pull request has reached.

README.md

nix-track-pr #

A command-line tool that follows nixpkgs pull requests through the branches they flow into, showing which branches and channels each merged pull request has reached so far.

Screenshot of nix-track-pr in action

Usage #

$ nix-track-pr 400000 '#401234'

Give it one or more pull request numbers, with or without a leading #. --version prints the version.

For each pull request, gh pr view supplies the title, the state, the base branch and the merge commit. The base branch decides which branches are checked, following the branch conventions in the nixpkgs contributing guide:

Base branch Branches checked
master master, nixos-unstable-small, nixpkgs-unstable, nixos-unstable
staging-next staging-next, then everything master gets
staging staging, staging-next, then everything master gets
release-YY.MM release-YY.MM, nixpkgs-YY.MM-darwin, nixos-YY.MM-small, nixos-YY.MM

Those branches are fetched into a local bare clone of nixpkgs, and git merge-base --is-ancestor decides whether each one contains the merge commit. The results are drawn as a table, one block per pull request.

Requirements #

gh and git must be available. gh must be logged in, since it talks to the GitHub API. Build options set the paths to both programs (-Dgh= and -Dgit=); the Nix package points them at the store paths, so it needs nothing on PATH.

The first run makes a bare clone of nixpkgs, which takes around 6 GB of disk space and many minutes. Later runs only fetch the branches they need, which is quick unless it has been a long time since the last run.

Cache directory #

The clone lives in nix-track-pr/nixpkgs inside the platform's cache directory, which known-folders finds:

Platform Cache directory
Linux and other Unix $XDG_CACHE_HOME, or ~/.cache if that is not set
macOS ~/Library/Caches
Windows %LOCALAPPDATA%

The directory is created if it does not exist.

Building #

The project is written in Zig 0.17. Nixpkgs does not package that version yet, so the flake takes the release build from zig-overlay. The flake builds for x86_64-linux, aarch64-linux and aarch64-darwin, the systems the overlay packages.

$ nix build                              # the package, in ./result
$ nix develop -c zig build               # a debug build, in ./zig-out
$ nix develop -c zig build test          # the tests

The Nix build has no network, so the Zig dependencies are fetched by Nix from build.zig.zon.nix, which zon2nix generates from build.zig.zon. Regenerate it whenever a dependency changes:

$ nix develop -c zon2nix --17 --nix=build.zig.zon.nix build.zig.zon

The last version that builds with Zig 0.16 is tagged v0.3.0, and lives on the zig-0.16 branch.

Where this lives #

The repository lives in three places that carry the same history. The Forgejo instance at https://git.jcollie.dev/jeff/nix-track-pr is the web-visible one:

$ git clone https://git.jcollie.dev/jeff/nix-track-pr.git

it is mirrored on Tangled at https://tangled.org/jcollie.dev/nix-track-pr, and it is also on the Radicle network, where the repository's identifier is

rad:z2qXwUZNDW57q9KahiRR9KnXSRmSb

and rad clone rad:z2qXwUZNDW57q9KahiRR9KnXSRmSb fetches it from any node that seeds it. Any of the three is the whole project.

License #

MIT. The project follows the REUSE specification, and reuse lint passes.

References cited #