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, we will list a few tips for using tools like this in the Nix context.
Commit selection
There are different ways to tweak git bisect
's commit selection to reduce the required builds:
git bisect start
flag--first-parent
: select merge commits, which depending on the repository can help for caching as well as commit stability.hydrasect
: select cached commits cached by Hydra, useful for bisecting nixpkgs. After each checkout rungit checkout $(hydrasect-search | head -1)
.nixpkgs-staging-bisecter
(nix-build
only): reduce number of derivations to be built.
Automating bisects
git bisect run
: runs the selected command until the culprit is found.nix-bisect
: helps better judge outcome (git bisect
'sgood
vsbad
skip
) and gives nicer outputs thangit bisect run
.
Flakes
Bisecting changes in a flake itself can just follow the regular bisecting process. Bisecting regressions in flakes' inputs is a bit different in the sense the repositories you are building is not the repository you are bisecting. In this case you can use:
--override-input
: nix flag that enables bisecting flakes' inputs--flake
flag on nix operations: allows overriding flake directory so you can use nix flake operations from e.g.git bisect run