1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2024-12-05 12:02:47 +00:00
nixpkgs/pkgs/build-support/mkshell/default.nix
2017-12-20 23:42:07 +00:00

47 lines
1.1 KiB
Nix

{ 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
mergeInputs = name:
let
op = item: sum: sum ++ item."${name}" or [];
nul = [];
list = [attrs] ++ inputsFrom;
in
lib.foldr op nul list;
rest = builtins.removeAttrs attrs [
"inputsFrom"
"buildInputs"
"nativeBuildInputs"
"propagatedBuildInputs"
"propagatedNativeBuildInputs"
];
in
stdenv.mkDerivation ({
name = "nix-shell";
phases = ["nobuildPhase"];
buildInputs = mergeInputs "buildInputs";
nativeBuildInputs = mergeInputs "nativeBuildInputs";
propagatedBuildInputs = mergeInputs "propagatedBuildInputs";
propagatedNativeBuildInputs = mergeInputs "propagatedNativeBuildInputs";
nobuildPhase = ''
echo
echo "This derivation is not meant to be built, aborting";
echo
exit 1
'';
} // rest)