stdenv: perform checks only when evaluating .drv and .out
This pushes check-meta evaluation to derivation evaluation step, leaving all other attributes accessible. Before this commit: > $ HOME=/homeless-shelter NIX_PATH=nixpkgs=$(pwd) nix-instantiate --eval --strict ./default.nix -A xen --argstr system aarch64-linux > Package ‘xen-4.5.5’ in pkgs/applications/virtualization/xen/generic.nix:226 is not supported on ‘aarch64-linux’, refusing to evaluate. as expected > $ HOME=/homeless-shelter NIX_PATH=nixpkgs=$(pwd) nix-instantiate --eval --strict ./default.nix -A xen.name --argstr system aarch64-linux > Package ‘xen-4.5.5’ in pkgs/applications/virtualization/xen/generic.nix:226 is not supported on ‘aarch64-linux’, refusing to evaluate. > $ HOME=/homeless-shelter NIX_PATH=nixpkgs=$(pwd) nix-instantiate --eval --strict ./default.nix -A xen.meta.description --argstr system aarch64-linux > Package ‘xen-4.5.5’ in pkgs/applications/virtualization/xen/generic.nix:226 is not supported on ‘aarch64-linux’, refusing to evaluate. which is unfortunate since its impossible to use packages in autogenerated documentation on all platforms. After this commit: > $ HOME=/homeless-shelter NIX_PATH=nixpkgs=$(pwd) nix-instantiate --eval --strict ./default.nix -A xen --argstr system aarch64-linux still fails > $ HOME=/homeless-shelter NIX_PATH=nixpkgs=$(pwd) nix-instantiate --eval --strict ./default.nix -A xen.name --argstr system aarch64-linux > "xen-4.5.5" > $ HOME=/homeless-shelter NIX_PATH=nixpkgs=$(pwd) nix-instantiate --eval --strict ./default.nix -A xen.meta.description --argstr system aarch64-linux > "Xen hypervisor and related components (vanilla)"
This commit is contained in:
parent
b1ca8517ee
commit
d1d5ecb3bf
@ -1,6 +1,5 @@
|
|||||||
# Extend a derivation with checks for brokenness, license, etc. Throw a
|
# Checks derivation meta and attrs for problems (like brokenness,
|
||||||
# descriptive error when the check fails; return `derivationArg` otherwise.
|
# licenses, etc).
|
||||||
# Note: no dependencies are checked in this step.
|
|
||||||
|
|
||||||
{ lib, config, system, meta, derivationArg, mkDerivationArg }:
|
{ lib, config, system, meta, derivationArg, mkDerivationArg }:
|
||||||
|
|
||||||
@ -196,13 +195,11 @@ let
|
|||||||
{ valid = false; reason = "unknown-meta"; errormsg = "has an invalid meta attrset:${lib.concatMapStrings (x: "\n\t - " + x) res}"; }
|
{ valid = false; reason = "unknown-meta"; errormsg = "has an invalid meta attrset:${lib.concatMapStrings (x: "\n\t - " + x) res}"; }
|
||||||
else { valid = true; };
|
else { valid = true; };
|
||||||
|
|
||||||
# Throw an error if trying to evaluate an non-valid derivation
|
validity = checkValidity attrs;
|
||||||
validityCondition =
|
|
||||||
let v = checkValidity attrs;
|
|
||||||
in if !v.valid
|
|
||||||
then handleEvalIssue (removeAttrs v ["valid"])
|
|
||||||
else true;
|
|
||||||
|
|
||||||
in
|
in validity // {
|
||||||
assert validityCondition;
|
# Throw an error if trying to evaluate an non-valid derivation
|
||||||
derivationArg
|
handled = if !validity.valid
|
||||||
|
then handleEvalIssue (removeAttrs validity ["valid"])
|
||||||
|
else true;
|
||||||
|
}
|
||||||
|
@ -182,6 +182,14 @@ rec {
|
|||||||
outputs = outputs';
|
outputs = outputs';
|
||||||
} else { }));
|
} else { }));
|
||||||
|
|
||||||
|
validity = import ./check-meta.nix {
|
||||||
|
inherit lib config meta derivationArg;
|
||||||
|
mkDerivationArg = attrs;
|
||||||
|
# Nix itself uses the `system` field of a derivation to decide where
|
||||||
|
# to build it. This is a bit confusing for cross compilation.
|
||||||
|
inherit (stdenv) system;
|
||||||
|
};
|
||||||
|
|
||||||
# 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
|
||||||
# passed to the builder and is not a dependency. But since we
|
# passed to the builder and is not a dependency. But since we
|
||||||
@ -207,15 +215,8 @@ rec {
|
|||||||
|
|
||||||
in
|
in
|
||||||
|
|
||||||
lib.addPassthru
|
lib.extendDerivation
|
||||||
(derivation (import ./check-meta.nix
|
validity.handled
|
||||||
{
|
|
||||||
inherit lib config meta derivationArg;
|
|
||||||
mkDerivationArg = attrs;
|
|
||||||
# Nix itself uses the `system` field of a derivation to decide where
|
|
||||||
# to build it. This is a bit confusing for cross compilation.
|
|
||||||
inherit (stdenv) system;
|
|
||||||
}))
|
|
||||||
({
|
({
|
||||||
overrideAttrs = f: mkDerivation (attrs // (f attrs));
|
overrideAttrs = f: mkDerivation (attrs // (f attrs));
|
||||||
inherit meta passthru;
|
inherit meta passthru;
|
||||||
@ -223,5 +224,7 @@ rec {
|
|||||||
# 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).
|
||||||
passthru);
|
passthru)
|
||||||
|
(derivation derivationArg);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user