087513bc11
The motivation for inputsFrom is to create a shell environment that is suitable for development of the packages listed in inputsFrom. This commit filters out any dependencies from one package in inputsFrom to another when computing the shell environment's inputs. This supports the use case where several closely related packages (perhaps even built from the same source tree) are being mutually developed. It is assumed that the user will configure their environment to resolve dependencies between these mutually developed packages.
50 lines
1.2 KiB
Nix
50 lines
1.2 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.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)
|