mkShell: compose shellHooks
Running the following expression with nix-shell:
let
pkgs = import <nixpkgs> {};
shell1 = pkgs.mkShell {
shellHook = ''
echo shell1
'';
};
shell2 = pkgs.mkShell {
shellHook = ''
echo shell2
'';
};
shell3 = pkgs.mkShell {
inputsFrom = [ shell1 shell2 ];
shellHook = ''
echo shell3
'';
};
in shell3
Will now results in:
shell2
shell1
shell3
Note that packages in the front of inputsFrom have precedence over
packages in the back. The outermost mkShell has precedence over all.
This commit is contained in:
parent
ba7e7aed08
commit
76ef802d3d
@ -25,6 +25,7 @@ let
|
|||||||
"nativeBuildInputs"
|
"nativeBuildInputs"
|
||||||
"propagatedBuildInputs"
|
"propagatedBuildInputs"
|
||||||
"propagatedNativeBuildInputs"
|
"propagatedNativeBuildInputs"
|
||||||
|
"shellHook"
|
||||||
];
|
];
|
||||||
in
|
in
|
||||||
|
|
||||||
@ -37,6 +38,9 @@ stdenv.mkDerivation ({
|
|||||||
propagatedBuildInputs = mergeInputs "propagatedBuildInputs";
|
propagatedBuildInputs = mergeInputs "propagatedBuildInputs";
|
||||||
propagatedNativeBuildInputs = mergeInputs "propagatedNativeBuildInputs";
|
propagatedNativeBuildInputs = mergeInputs "propagatedNativeBuildInputs";
|
||||||
|
|
||||||
|
shellHook = lib.concatStringsSep "\n" (lib.catAttrs "shellHook"
|
||||||
|
(lib.reverseList inputsFrom ++ [attrs]));
|
||||||
|
|
||||||
nobuildPhase = ''
|
nobuildPhase = ''
|
||||||
echo
|
echo
|
||||||
echo "This derivation is not meant to be built, aborting";
|
echo "This derivation is not meant to be built, aborting";
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user