-
-
Notifications
You must be signed in to change notification settings - Fork 14.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
stdenv: wrap phase running actions of genericBuild #230874
Conversation
pkgs/stdenv/generic/setup.sh
Outdated
@@ -1539,6 +1539,44 @@ showPhaseFooter() { | |||
} | |||
|
|||
|
|||
runPhase() { | |||
local curPhase="${1%Phase}Phase" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's not do this
Provide a `runPhase` function which wraps the phase running action of genericBuild. The new function can be used as an interface by `nix develop`, i.e. `nix develop some#flake --build` may just call `runPhase build`, which makes its behavior more consistent with `nix build`. In preparation of fixing NixOS/nix#6202
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hello> somePhase
hello> build failed in somePhase with exit code 1
hello> To attach install cntr and run the following command as root:
hello> cntr attach -t command cntr-/nix/store/x82brk9g33fhnq33nwb9hl6s2zqmfzzh-hello-2.12.1
diff --git a/pkgs/by-name/he/hello/package.nix b/pkgs/by-name/he/hello/package.nix
index f1b056faf640..c632ba1e9835 100644
--- a/pkgs/by-name/he/hello/package.nix
+++ b/pkgs/by-name/he/hello/package.nix
@@ -5,6 +5,7 @@
, nixos
, testers
, hello
+, breakpointHook
}:
stdenv.mkDerivation (finalAttrs: {
@@ -28,6 +29,14 @@ stdenv.mkDerivation (finalAttrs: {
(nixos { environment.noXlibs = true; }).pkgs.hello;
};
+ nativeBuildInputs = [ breakpointHook ];
+
+ buildPhase = ''
+ runPhase somePhase
+ '';
+
+ somePhase = ''exit 1'';
+
passthru.tests.run = callPackage ./test.nix { hello = finalAttrs.finalPackage; };
meta = with lib; {
breakpointHook
uses $curPhase
and it works
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/nix-build-phases-run-nix-build-phases-interactively/36090/4 |
Provide a
runPhase
function which wraps the phase running action of genericBuild. The new function can be used as an interface bynix develop
, i.e.nix develop some#flake --build
may just callrunPhase build
, which makes its behavior more consistent withnix build
. In preparation of fixing NixOS/nix#6202Description of changes
Things done
sandbox = true
set innix.conf
? (See Nix manual)nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"
. Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/
)