Bisecting: Difference between revisions
→Flakes: - nix-prefetch-url + nix-hash -> nix flake prefetch |
add note on hydrasect being broken |
||
(3 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
[https://git-scm.com/docs/git-bisect 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, | [https://git-scm.com/docs/git-bisect 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 <code>git bisect</code>'s commit selection to reduce the required builds: | |||
* | * <code>git bisect start</code> flag [https://git-scm.com/docs/git-bisect#Documentation/git-bisect.txt---first-parent <code>--first-parent</code>]: select merge commits, which depending on the repository can help for caching as well as commit stability. | ||
* [https://github.com/ | * <s>[https://git.qyliss.net/hydrasect/about/ <code>hydrasect</code>]: select cached commits cached by Hydra</s> - [https://github.com/NixOS/nixpkgs/issues/323985#issuecomment-2210893775 broken] | ||
* [https://git. | * [https://github.com/symphorien/nixpkgs-staging-bisecter <code>nixpkgs-staging-bisecter</code>] (<code>nix-build</code> only): reduce number of derivations to be built. | ||
* [https://github.com/ | == Automating bisects == | ||
* [https://git-scm.com/docs/git-bisect#_bisect_run <code>git bisect run</code>]: runs the selected command until the culprit is found. | |||
* [https://github.com/timokau/nix-bisect <code>nix-bisect</code>]: helps better judge outcome (<code>git bisect</code>'s <code>good</code> vs <code>bad</code> <code>skip</code>) and gives nicer outputs than <code>git bisect run</code>. | |||
== Flakes == | == Flakes == | ||
Bisecting changes in a flake itself can just follow the regular bisecting process. | Bisecting changes in a [[flake]] itself can just follow the regular bisecting process. | ||
Bisecting regressions in | 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: | ||
* <code>--override-input</code>: nix flag that enables bisecting flakes' inputs | |||
* <code>--flake</code> flag on nix operations: allows overriding flake directory so you can use nix flake operations from e.g. <code>git bisect run</code> | |||
[[Category:Version control]] |
Latest revision as of 19:20, 5 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, 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.- brokenhydrasect
: select cached commits cached by Hydranixpkgs-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