A `nix run`able command for debugging failed derivation builds

how to run

nix run github:letsql/nix-utils#letsql-debug-drv "$drvPath"
currently, its the default app, so you can also use
nix run github:letsql/nix-utils "$drvPath"

what it does

given a drv path (likely generated by a failed build message), it

  • runs from a temporary director
  • uses nix-shell’s --command argument to define helpers, including run-next-phase that automagically iterates through all the appropriate phases

example invocation

$ pkgName=asciinema
$ drvPath=$(nix derivation show nixpkgs#$pkgName | nix-shell --packages jq --command "jq --raw-output keys[0]" 2>/dev/null)
$ nix run github:letsql/nix-utils#letsql-debug-drv "$drvPath"
+ drvPath=/nix/store/xn6fxh4gj6h8p0ma48m5sccsdkndd9lz-asciinema-2.4.0.drv
++ nix-store --query --binding pname /nix/store/xn6fxh4gj6h8p0ma48m5sccsdkndd9lz-asciinema-2.4.0.drv
+ name=asciinema
++ mktemp -d -t nix-debug-asciinema.XXXXX
+ export out=/tmp/nix-debug-asciinema.N4Jpa
+ out=/tmp/nix-debug-asciinema.N4Jpa
+ pushd /tmp/nix-debug-asciinema.N4Jpa
/tmp/nix-debug-asciinema.N4Jpa ~/repos/github/nix-utils
+ nix-shell --command 'drvPath="/nix/store/xn6fxh4gj6h8p0ma48m5sccsdkndd9lz-asciinema-2.4.0.drv"; source /nix/store/3y49sm3c3qmnbg5v8aw2jf0sbw14mxsg-letsql-debug-drv-setup.sh; return' /nix/store/xn6fxh4gj6h8p0ma48m5sccsdkndd9lz-asciinema-2.4.0.drv
Sourcing python-remove-tests-dir-hook
Sourcing python-catch-conflicts-hook.sh
Sourcing python-remove-bin-bytecode-hook.sh
Sourcing pypa-build-hook
Using pypaBuildPhase
Sourcing python-runtime-deps-check-hook
Using pythonRuntimeDepsCheckHook
Sourcing pypa-install-hook
Using pypaInstallPhase
Sourcing python-imports-check-hook.sh
Using pythonImportsCheckPhase
Sourcing python-namespaces-hook
Sourcing python-catch-conflicts-hook.sh
Sourcing pytest-check-hook
Using pytestCheckPhase
18 phases: unpackPhase patchPhase updateAutotoolsGnuConfigScriptsPhase configurePhase buildPhase checkPhase pythonRuntimeDepsCheckHook installPhase pythonOutputDistPhase fixupPhase installCheckPhase pythonCatchConflictsPhase pythonRemoveBinBytecodePhase pythonImportsCheckPhase pytestCheckPhase pytestcachePhase pytestRemoveBytecodePhase distPhase
use run-next-phase to iterate through phases
next phase: unpackPhase

[nix-shell:/tmp/nix-debug-asciinema.N4Jpa]$

thoughts?

4 Likes