git.iko.soy/typeable/nixpkgs
on master help sign in
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.

commit76ef802d3d60cc4d199f19ba69e8bcfe63b88e7b authorBas van Dijk <v.dijk.bas@gmail.com> dateSun 23 Jun 2019, 21:11 (7 years ago) parentba7e7ae
1 file changed+4
pkgs/build-support/mkshell/default.nix+4
pkgs/build-support/mkshell/default.nix+4
@@ -25,6 +25,7 @@ let
2525 "nativeBuildInputs"
2626 "propagatedBuildInputs"
2727 "propagatedNativeBuildInputs"
28+ "shellHook"
2829 ];
2930in
3031
@@ -37,6 +38,9 @@ stdenv.mkDerivation ({
3738 propagatedBuildInputs = mergeInputs "propagatedBuildInputs";
3839 propagatedNativeBuildInputs = mergeInputs "propagatedNativeBuildInputs";
3940
41+ shellHook = lib.concatStringsSep "\n" (lib.catAttrs "shellHook"
42+ (lib.reverseList inputsFrom ++ [attrs]));
43+
4044 nobuildPhase = ''
4145 echo
4246 echo "This derivation is not meant to be built, aborting";