Bisecting

From NixOS Wiki
Revision as of 09:16, 2 July 2024 by Kiara (talk | contribs) (→‎nixpkgs: - reword bisect tools)

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 package lolcat broke since nixos-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: in automated bisects handle picking bisect bad / bisect skip and give nicer outputs
  • hydrasect: prioritize hydra-cached commits, nixpkgs only. After each checkout run git checkout $(hydrasect-search | head -1).
  • nixpkgs-staging-bisecter: reduce number of derivations to be built, nix-build only.

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 flake prefetch, jq and sed, this process can be scripted.