2017-12-21 00:42:07 +01:00
|
|
|
{ lib, stdenv }:
|
|
|
|
|
|
|
|
# A special kind of derivation that is only meant to be consumed by the
|
|
|
|
# nix-shell.
|
|
|
|
{
|
|
|
|
inputsFrom ? [], # a list of derivations whose inputs will be made available to the environment
|
|
|
|
buildInputs ? [],
|
|
|
|
nativeBuildInputs ? [],
|
|
|
|
propagatedBuildInputs ? [],
|
|
|
|
propagatedNativeBuildInputs ? [],
|
|
|
|
...
|
|
|
|
}@attrs:
|
|
|
|
let
|
2019-06-23 21:39:29 +02:00
|
|
|
mergeInputs = name: lib.concatLists (lib.catAttrs name
|
|
|
|
([attrs] ++ inputsFrom));
|
2017-12-21 00:42:07 +01:00
|
|
|
|
|
|
|
rest = builtins.removeAttrs attrs [
|
|
|
|
"inputsFrom"
|
|
|
|
"buildInputs"
|
|
|
|
"nativeBuildInputs"
|
|
|
|
"propagatedBuildInputs"
|
|
|
|
"propagatedNativeBuildInputs"
|
2019-06-23 21:11:49 +02:00
|
|
|
"shellHook"
|
2017-12-21 00:42:07 +01:00
|
|
|
];
|
|
|
|
in
|
|
|
|
|
|
|
|
stdenv.mkDerivation ({
|
|
|
|
name = "nix-shell";
|
|
|
|
phases = ["nobuildPhase"];
|
|
|
|
|
|
|
|
buildInputs = mergeInputs "buildInputs";
|
|
|
|
nativeBuildInputs = mergeInputs "nativeBuildInputs";
|
|
|
|
propagatedBuildInputs = mergeInputs "propagatedBuildInputs";
|
|
|
|
propagatedNativeBuildInputs = mergeInputs "propagatedNativeBuildInputs";
|
|
|
|
|
2019-06-23 21:11:49 +02:00
|
|
|
shellHook = lib.concatStringsSep "\n" (lib.catAttrs "shellHook"
|
|
|
|
(lib.reverseList inputsFrom ++ [attrs]));
|
|
|
|
|
2017-12-21 00:42:07 +01:00
|
|
|
nobuildPhase = ''
|
|
|
|
echo
|
|
|
|
echo "This derivation is not meant to be built, aborting";
|
|
|
|
echo
|
|
|
|
exit 1
|
|
|
|
'';
|
|
|
|
} // rest)
|