mkDerivation: Use function arguments

This commit is contained in:
Eelco Dolstra 2015-03-06 16:42:06 +01:00
parent 0e2257966f
commit 8b2f209838

View file

@ -83,7 +83,15 @@ let
# Add a utility function to produce derivations that use this # Add a utility function to produce derivations that use this
# stdenv and its shell. # stdenv and its shell.
mkDerivation = attrs: mkDerivation =
{ buildInputs ? []
, nativeBuildInputs ? []
, propagatedBuildInputs ? []
, propagatedNativeBuildInputs ? []
, crossConfig ? null
, meta ? {}
, passthru ? {}
, ... } @ attrs:
let let
pos = pos =
if attrs.meta.description or null != null then if attrs.meta.description or null != null then
@ -122,13 +130,7 @@ let
lib.addPassthru (derivation ( lib.addPassthru (derivation (
(removeAttrs attrs ["meta" "passthru" "crossAttrs"]) (removeAttrs attrs ["meta" "passthru" "crossAttrs"])
// (let //
buildInputs = attrs.buildInputs or [];
nativeBuildInputs = attrs.nativeBuildInputs or [];
propagatedBuildInputs = attrs.propagatedBuildInputs or [];
propagatedNativeBuildInputs = attrs.propagatedNativeBuildInputs or [];
crossConfig = attrs.crossConfig or null;
in
{ {
builder = attrs.realBuilder or shell; builder = attrs.realBuilder or shell;
args = attrs.args or ["-e" (attrs.builder or ./default-builder.sh)]; args = attrs.args or ["-e" (attrs.builder or ./default-builder.sh)];
@ -144,7 +146,7 @@ let
nativeBuildInputs = nativeBuildInputs ++ (if crossConfig == null then buildInputs else []); nativeBuildInputs = nativeBuildInputs ++ (if crossConfig == null then buildInputs else []);
propagatedNativeBuildInputs = propagatedNativeBuildInputs ++ propagatedNativeBuildInputs = propagatedNativeBuildInputs ++
(if crossConfig == null then propagatedBuildInputs else []); (if crossConfig == null then propagatedBuildInputs else []);
}))) ( })) (
{ {
# The meta attribute is passed in the resulting attribute set, # The meta attribute is passed in the resulting attribute set,
# but it's not part of the actual derivation, i.e., it's not # but it's not part of the actual derivation, i.e., it's not
@ -152,15 +154,15 @@ let
# include it in the result, it *is* available to nix-env for # include it in the result, it *is* available to nix-env for
# queries. We also a meta.position attribute here to # queries. We also a meta.position attribute here to
# identify the source location of the package. # identify the source location of the package.
meta = attrs.meta or {} // (if pos != null then { meta = meta // (if pos != null then {
position = pos.file + ":" + (toString pos.line); position = pos.file + ":" + toString pos.line;
} else {}); } else {});
passthru = attrs.passthru or {}; inherit passthru;
} // } //
# Pass through extra attributes that are not inputs, but # Pass through extra attributes that are not inputs, but
# should be made available to Nix expressions using the # should be made available to Nix expressions using the
# derivation (e.g., in assertions). # derivation (e.g., in assertions).
(attrs.passthru or {})); passthru);
# The stdenv that we are producing. # The stdenv that we are producing.
result = result =