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.
(If you don't have git available, you can make it available in a shell using:)
nix --extra-experimental-features 'nix-command flakes' shell nixpkgs#gitgit bisect start $BAD $GOOD && git bisect run $CMDeither:
- nix-bisect: smartly pick
bisect bad/skipin 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
- run in
nixpkgsrepo, e.g. forsignal-desktop:
cat >> .test<< EOF
#! /usr/bin/env bash
$(nix-build -A signal-desktop)/bin/signal-desktop --use-tray-icon --no-sandbox
EOF
chmod +x ./test
git bisect start -- pkgs/applications/networking/instant-messengers/signal-desktop/
git bisect bad
git bisect run sh -c './test; [ $? -eq 0 ]'Place bisect.sh in the system repo, then from there run:
chmod +x ./bisect.sh
git stash push flake.lockFrom the dependency's repo, run steps like:
git bisect start $BAD $GOOD
export SYSTEM_REPO=/etc/nixos
export DEPENDENCY_INPUT=$(basename $PWD) # e.g. nixpkgs
export DEPENDENCY_URL=https://github.com/NixOS/nixpkgs # exampleThen, if judgement needs manual intervention, run cycles of:
$SYSTEM_REPO/bisect.sh $DEPENDENCY_INPUT $DEPENDENCY_URL $SYSTEM_REPO
# git checkout $(hydrasect-search | head -1) # only if the dep is nixpkgs
# <TEST>
git bisect good
git bisect badOr, if judgement can be automated (COMMAND optional, will rebuild):
git bisect run $SYSTEM_REPO/bisect.sh $DEPENDENCY_INPUT $DEPENDENCY_URL $SYSTEM_REPO && <COMMAND>
looks like there's
git bisect run sudo nixos-rebuild dry-activate --override-input nixpkgs . --flake /etc/nixos#default😳