1 { lib, stdenv, buildEnv }:
3 # A special kind of derivation that is only meant to be consumed by the
6 , # a list of packages to add to the shell environment
8 , # propagate all the inputs from the given derivations
11 , nativeBuildInputs ? [ ]
12 , propagatedBuildInputs ? [ ]
13 , propagatedNativeBuildInputs ? [ ]
18 (attrs.${name} or [ ]) ++
19 # 1. get all `{build,nativeBuild,...}Inputs` from the elements of `inputsFrom`
20 # 2. since that is a list of lists, `flatten` that into a regular list
21 # 3. filter out of the result everything that's in `inputsFrom` itself
22 # this leaves actual dependencies of the derivations in `inputsFrom`, but never the derivations themselves
23 (lib.subtractLists inputsFrom (lib.flatten (lib.catAttrs name inputsFrom)));
25 rest = builtins.removeAttrs attrs [
31 "propagatedBuildInputs"
32 "propagatedNativeBuildInputs"
37 stdenv.mkDerivation ({
40 buildInputs = mergeInputs "buildInputs";
41 nativeBuildInputs = packages ++ (mergeInputs "nativeBuildInputs");
42 propagatedBuildInputs = mergeInputs "propagatedBuildInputs";
43 propagatedNativeBuildInputs = mergeInputs "propagatedNativeBuildInputs";
45 shellHook = lib.concatStringsSep "\n" (lib.catAttrs "shellHook"
46 (lib.reverseList inputsFrom ++ [ attrs ]));
48 phases = [ "buildPhase" ];
51 { echo "------------------------------------------------------------";
52 echo " WARNING: the existence of this path is not guaranteed.";
53 echo " It is an internal implementation detail for pkgs.mkShell.";
54 echo "------------------------------------------------------------";
56 # Record all build inputs as runtime dependencies
61 preferLocalBuild = true;