2020-04-24 23:36:52 +00:00
|
|
|
{ lib, stdenv }:
|
|
|
|
|
|
|
|
# A special kind of derivation that is only meant to be consumed by the
|
|
|
|
# nix-shell.
|
|
|
|
{
|
2021-05-20 23:08:51 +00:00
|
|
|
# a list of packages to add to the shell environment
|
|
|
|
packages ? [ ]
|
|
|
|
, # propagate all the inputs from the given derivations
|
|
|
|
inputsFrom ? [ ]
|
|
|
|
, buildInputs ? [ ]
|
|
|
|
, nativeBuildInputs ? [ ]
|
|
|
|
, propagatedBuildInputs ? [ ]
|
|
|
|
, propagatedNativeBuildInputs ? [ ]
|
|
|
|
, ...
|
2020-04-24 23:36:52 +00:00
|
|
|
}@attrs:
|
|
|
|
let
|
|
|
|
mergeInputs = name: lib.concatLists (lib.catAttrs name
|
2021-05-20 23:08:51 +00:00
|
|
|
([ attrs ] ++ inputsFrom));
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
rest = builtins.removeAttrs attrs [
|
2021-05-20 23:08:51 +00:00
|
|
|
"packages"
|
2020-04-24 23:36:52 +00:00
|
|
|
"inputsFrom"
|
|
|
|
"buildInputs"
|
|
|
|
"nativeBuildInputs"
|
|
|
|
"propagatedBuildInputs"
|
|
|
|
"propagatedNativeBuildInputs"
|
|
|
|
"shellHook"
|
|
|
|
];
|
|
|
|
in
|
|
|
|
|
|
|
|
stdenv.mkDerivation ({
|
|
|
|
name = "nix-shell";
|
2021-05-20 23:08:51 +00:00
|
|
|
phases = [ "nobuildPhase" ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
buildInputs = mergeInputs "buildInputs";
|
2021-05-20 23:08:51 +00:00
|
|
|
nativeBuildInputs = packages ++ (mergeInputs "nativeBuildInputs");
|
2020-04-24 23:36:52 +00:00
|
|
|
propagatedBuildInputs = mergeInputs "propagatedBuildInputs";
|
|
|
|
propagatedNativeBuildInputs = mergeInputs "propagatedNativeBuildInputs";
|
|
|
|
|
|
|
|
shellHook = lib.concatStringsSep "\n" (lib.catAttrs "shellHook"
|
2021-05-20 23:08:51 +00:00
|
|
|
(lib.reverseList inputsFrom ++ [ attrs ]));
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
nobuildPhase = ''
|
|
|
|
echo
|
|
|
|
echo "This derivation is not meant to be built, aborting";
|
|
|
|
echo
|
|
|
|
exit 1
|
|
|
|
'';
|
|
|
|
} // rest)
|