Bisecting
Bisecting is a feature of version control systems such as Git and Mercurial to easily pinpoint regressions. Owing to their reproducibility, Nix and NixOS are well-suited to this. As a result, there are a few common use-cases for Nix.
nixpkgs
either:
- directly bisect, say from the root of the nixpkgs repository run
git bisect start --first-parent master nixos-24.05 && git bisect run nix build -f . lolcat
if packagelolcat
broke sincenixos-24.05
. This uses git bisect run to run the test until the culprit is found, while the--first-parent
flag selects merge commits, which in nixpkgs should be cached in Hydra. - nix-bisect: smartly pick
bisect bad/skip
in automated bisects and give nicer outputs - hydrasect: prioritize cached commits in nixpkgs bisects - unfortunately still lacks nix package/flake
- after each checkout run
git checkout $(hydrasect-search | head -1)
- after each checkout run
- nixpkgs-staging-bisecter: like hydrasect but minimize how many derivations you will build even in staging
Flakes
Bisecting changes in a flake itself can just follow the regular bisecting process.
Bisecting regressions in flakes' inputs typically involves updating the dependency's rev
and narHash
in the flake.lock
file. Using tools like nix-prefetch-url
, nix-hash
, jq
and sed
, this process can be scripted.