Bisecting: Difference between revisions

From NixOS Wiki
Klinger (talk | contribs)
Kiara (talk | contribs)
→‎nixpkgs: - reword bisect tools
Line 6: Line 6:


* directly bisect, say from the root of the nixpkgs repository run <code>git bisect start --first-parent master nixos-24.05 && git bisect run nix build -f . lolcat</code> if package <code>lolcat</code> broke since <code>nixos-24.05</code>. This uses [https://git-scm.com/docs/git-bisect#_bisect_run git bisect run] to run the test until the culprit is found, while the [https://git-scm.com/docs/git-bisect#Documentation/git-bisect.txt---first-parent <code>--first-parent</code>] flag selects merge commits, which in nixpkgs should be cached in Hydra.
* directly bisect, say from the root of the nixpkgs repository run <code>git bisect start --first-parent master nixos-24.05 && git bisect run nix build -f . lolcat</code> if package <code>lolcat</code> broke since <code>nixos-24.05</code>. This uses [https://git-scm.com/docs/git-bisect#_bisect_run git bisect run] to run the test until the culprit is found, while the [https://git-scm.com/docs/git-bisect#Documentation/git-bisect.txt---first-parent <code>--first-parent</code>] flag selects merge commits, which in nixpkgs should be cached in Hydra.
* [https://github.com/timokau/nix-bisect nix-bisect]: smartly pick <code>bisect bad/skip</code> in automated bisects and give nicer outputs
* [https://github.com/timokau/nix-bisect nix-bisect]: in automated bisects handle picking <code>bisect bad</code> / <code>bisect skip</code> and give nicer outputs
* [https://git.qyliss.net/hydrasect/about/ hydrasect]: prioritize cached commits in nixpkgs bisects - unfortunately still lacks nix package/flake
* [https://git.qyliss.net/hydrasect/about/ hydrasect]: prioritize hydra-cached commits, nixpkgs only. After each checkout run <code>git checkout $(hydrasect-search | head -1)</code>.
** after each checkout run <code>git checkout $(hydrasect-search | head -1)</code>
* [https://github.com/symphorien/nixpkgs-staging-bisecter nixpkgs-staging-bisecter]: reduce number of derivations to be built, <code>nix-build</code> only.
* [https://github.com/symphorien/nixpkgs-staging-bisecter nixpkgs-staging-bisecter]: like hydrasect but minimize how many derivations you will build even in staging


== Flakes ==
== Flakes ==

Revision as of 09:16, 2 July 2024

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.