mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-12-21 21:23:06 +00:00
c524608dca
I somehow accidentally left out the lib.flatten from mergeInputs. Without it, subtractLists won't ever remove anything from the inputs since the inputs will be a list of lists.
51 lines
1.3 KiB
Nix
51 lines
1.3 KiB
Nix
{ lib, stdenv }:
|
|
|
|
# A special kind of derivation that is only meant to be consumed by the
|
|
# nix-shell.
|
|
{
|
|
# a list of packages to add to the shell environment
|
|
packages ? [ ]
|
|
, # propagate all the inputs from the given derivations
|
|
inputsFrom ? [ ]
|
|
, buildInputs ? [ ]
|
|
, nativeBuildInputs ? [ ]
|
|
, propagatedBuildInputs ? [ ]
|
|
, propagatedNativeBuildInputs ? [ ]
|
|
, ...
|
|
}@attrs:
|
|
let
|
|
mergeInputs = name:
|
|
(attrs.${name} or []) ++
|
|
(lib.subtractLists inputsFrom (lib.flatten (lib.catAttrs name inputsFrom)));
|
|
|
|
rest = builtins.removeAttrs attrs [
|
|
"packages"
|
|
"inputsFrom"
|
|
"buildInputs"
|
|
"nativeBuildInputs"
|
|
"propagatedBuildInputs"
|
|
"propagatedNativeBuildInputs"
|
|
"shellHook"
|
|
];
|
|
in
|
|
|
|
stdenv.mkDerivation ({
|
|
name = "nix-shell";
|
|
phases = [ "nobuildPhase" ];
|
|
|
|
buildInputs = mergeInputs "buildInputs";
|
|
nativeBuildInputs = packages ++ (mergeInputs "nativeBuildInputs");
|
|
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";
|
|
echo
|
|
exit 1
|
|
'';
|
|
} // rest)
|