From 76ef802d3d60cc4d199f19ba69e8bcfe63b88e7b Mon Sep 17 00:00:00 2001 From: Bas van Dijk Date: Sun, 23 Jun 2019 21:11:49 +0200 Subject: [PATCH] mkShell: compose shellHooks Running the following expression with nix-shell: let pkgs = import {}; 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. --- pkgs/build-support/mkshell/default.nix | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkgs/build-support/mkshell/default.nix b/pkgs/build-support/mkshell/default.nix index a98b4affacb..69897459088 100644 --- a/pkgs/build-support/mkshell/default.nix +++ b/pkgs/build-support/mkshell/default.nix @@ -25,6 +25,7 @@ let "nativeBuildInputs" "propagatedBuildInputs" "propagatedNativeBuildInputs" + "shellHook" ]; in @@ -37,6 +38,9 @@ stdenv.mkDerivation ({ propagatedBuildInputs = mergeInputs "propagatedBuildInputs"; propagatedNativeBuildInputs = mergeInputs "propagatedNativeBuildInputs"; + shellHook = lib.concatStringsSep "\n" (lib.catAttrs "shellHook" + (lib.reverseList inputsFrom ++ [attrs])); + nobuildPhase = '' echo echo "This derivation is not meant to be built, aborting";