blob: 8361126263514b9d976e2065b13276f7a038d298 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
{
lib,
stdenv,
}:
# A special kind of derivation that is only meant to be consumed by the
# nix-shell.
lib.extendMkDerivation {
constructDrv = stdenv.mkDerivation;
excludeDrvArgNames = [
"packages"
"inputsFrom"
];
extendDrvArgs =
_finalAttrs:
{
name ? "nix-shell",
# a list of packages to add to the shell environment
packages ? [ ],
# propagate all the inputs from the given derivations
inputsFrom ? [ ],
...
}@attrs:
let
mergeInputs =
name:
(attrs.${name} or [ ])
++
# 1. get all `{build,nativeBuild,...}Inputs` from the elements of `inputsFrom`
# 2. since that is a list of lists, `flatten` that into a regular list
# 3. filter out of the result everything that's in `inputsFrom` itself
# this leaves actual dependencies of the derivations in `inputsFrom`, but never the derivations themselves
(lib.subtractLists inputsFrom (lib.flatten (lib.catAttrs name inputsFrom)));
in
{
inherit name;
buildInputs = mergeInputs "buildInputs";
nativeBuildInputs = packages ++ (mergeInputs "nativeBuildInputs");
propagatedBuildInputs = mergeInputs "propagatedBuildInputs";
propagatedNativeBuildInputs = mergeInputs "propagatedNativeBuildInputs";
shellHook = lib.concatStringsSep "\n" (
lib.catAttrs "shellHook" (lib.reverseList inputsFrom ++ [ attrs ])
);
phases = attrs.phases or [ "buildPhase" ];
buildPhase =
attrs.buildPhase or ''
{ echo "------------------------------------------------------------";
echo " WARNING: the existence of this path is not guaranteed.";
echo " It is an internal implementation detail for pkgs.mkShell.";
echo "------------------------------------------------------------";
echo;
# Record all build inputs as runtime dependencies
export;
} >> "$out"
'';
preferLocalBuild = attrs.preferLocalBuild or true;
allowSubstitutes = attrs.allowSubstitutes or false;
};
}
|