mirror of
https://github.com/NixOS/nixpkgs.git
synced 2026-06-05 21:03:40 +00:00
check-meta: only take hostPlatform for functions requiring it
By doing this, we can cache the rest of the file, including the import of problems.nix. This allows genCheckProblems to be cached on every bootstrapping stage, and not re-called each time.
This commit is contained in:
@@ -361,7 +361,11 @@ lib.makeScope
|
||||
gnutar = gnutar-latest;
|
||||
};
|
||||
|
||||
inherit (callPackage ./utils.nix { }) derivationWithMeta writeTextFile writeText;
|
||||
inherit (callPackage ./utils.nix { inherit hostPlatform; })
|
||||
derivationWithMeta
|
||||
writeTextFile
|
||||
writeText
|
||||
;
|
||||
test = kaem.runCommand "minimal-bootstrap-test" { } (
|
||||
''
|
||||
echo ${bash.tests.get-version}
|
||||
|
||||
@@ -6,7 +6,12 @@
|
||||
kaem,
|
||||
mescc-tools-extra,
|
||||
checkMeta,
|
||||
hostPlatform,
|
||||
}:
|
||||
let
|
||||
assertValidity = checkMeta.assertValidity hostPlatform;
|
||||
commonMeta = checkMeta.commonMeta hostPlatform;
|
||||
in
|
||||
rec {
|
||||
maybeContentAddressed = lib.optionalAttrs config.contentAddressedByDefault {
|
||||
__contentAddressed = true;
|
||||
@@ -18,8 +23,8 @@ rec {
|
||||
attrs:
|
||||
let
|
||||
passthru = attrs.passthru or { };
|
||||
validity = checkMeta.assertValidity { inherit meta attrs; };
|
||||
meta = checkMeta.commonMeta { inherit validity attrs; };
|
||||
validity = assertValidity { inherit meta attrs; };
|
||||
meta = commonMeta { inherit validity attrs; };
|
||||
baseDrv = derivation (
|
||||
{
|
||||
inherit (buildPlatform) system;
|
||||
|
||||
@@ -47,7 +47,7 @@ let
|
||||
checkMeta = testPkgs.callPackage ./check-meta.nix { };
|
||||
tryEval = expression: builtins.tryEval (builtins.deepSeq expression expression);
|
||||
actual = tryEval (
|
||||
checkMeta.assertValidity {
|
||||
checkMeta.assertValidity pkgs.stdenv.hostPlatform {
|
||||
meta = pkg.meta;
|
||||
attrs = pkg;
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
{
|
||||
lib,
|
||||
config,
|
||||
hostPlatform,
|
||||
}:
|
||||
|
||||
let
|
||||
@@ -122,6 +121,7 @@ let
|
||||
|
||||
# Logical inversion of meta.availableOn for hostPlatform
|
||||
hasUnsupportedPlatform =
|
||||
hostPlatform:
|
||||
let
|
||||
inherit (hostPlatform) system;
|
||||
# in almost all cases, meta.platforms is a simple list of strings, and we
|
||||
@@ -416,6 +416,10 @@ let
|
||||
# !!! reason strings are hardcoded into OfBorg, make sure to keep them in sync
|
||||
# Along with a boolean flag for each reason
|
||||
checkValidity =
|
||||
hostPlatform:
|
||||
let
|
||||
hasUnsupportedPlatform' = hasUnsupportedPlatform hostPlatform;
|
||||
in
|
||||
attrs:
|
||||
if !attrs ? meta then
|
||||
null
|
||||
@@ -458,7 +462,7 @@ let
|
||||
msg = "contains elements not built from source (‘${showSourceType attrs.meta.sourceProvenance}’)";
|
||||
remediation = remediate_allowlist "NonSource" (remediate_predicate "allowNonSourcePredicate" attrs);
|
||||
}
|
||||
else if hasUnsupportedPlatform attrs && !allowUnsupportedSystem then
|
||||
else if hasUnsupportedPlatform' attrs && !allowUnsupportedSystem then
|
||||
let
|
||||
toPretty' = toPretty {
|
||||
allowPrettyValues = true;
|
||||
@@ -518,9 +522,13 @@ let
|
||||
# passed to the builder and is not a dependency. But since we
|
||||
# include it in the result, it *is* available to nix-env for queries.
|
||||
# Example:
|
||||
# meta = checkMeta.commonMeta { inherit validity attrs pos references; };
|
||||
# validity = checkMeta.assertValidity { inherit meta attrs; };
|
||||
# meta = checkMeta.commonMeta hostPlatform { inherit validity attrs pos references; };
|
||||
# validity = checkMeta.assertValidity hostPlatform { inherit meta attrs; };
|
||||
commonMeta =
|
||||
hostPlatform:
|
||||
let
|
||||
hasUnsupportedPlatform' = hasUnsupportedPlatform hostPlatform;
|
||||
in
|
||||
{
|
||||
validity,
|
||||
attrs,
|
||||
@@ -659,7 +667,7 @@ let
|
||||
# Expose the result of the checks for everyone to see.
|
||||
unfree = hasUnfreeLicense attrs;
|
||||
broken = isMarkedBroken attrs;
|
||||
unsupported = hasUnsupportedPlatform attrs;
|
||||
unsupported = hasUnsupportedPlatform' attrs;
|
||||
insecure = isMarkedInsecure attrs;
|
||||
|
||||
available =
|
||||
@@ -705,9 +713,13 @@ let
|
||||
builtins.seq (foldl' giveWarning null warnings) withError;
|
||||
|
||||
assertValidity =
|
||||
hostPlatform:
|
||||
let
|
||||
checkValidity' = checkValidity hostPlatform;
|
||||
in
|
||||
{ meta, attrs }:
|
||||
let
|
||||
invalid = checkValidity attrs;
|
||||
invalid = checkValidity' attrs;
|
||||
problems = checkProblems attrs;
|
||||
in
|
||||
if isNull invalid then
|
||||
|
||||
@@ -189,6 +189,9 @@ let
|
||||
structuredAttrsByDefault = config.structuredAttrsByDefault or false;
|
||||
inherit (config) enableParallelBuildingByDefault contentAddressedByDefault;
|
||||
userHook = config.stdenv.userHook or null;
|
||||
checkMeta = import ./check-meta.nix {
|
||||
inherit lib config;
|
||||
};
|
||||
in
|
||||
stdenv:
|
||||
|
||||
@@ -196,6 +199,11 @@ let
|
||||
inherit (import ../../build-support/lib/cmake.nix { inherit lib stdenv; }) makeCMakeFlags;
|
||||
inherit (import ../../build-support/lib/meson.nix { inherit lib stdenv; }) makeMesonFlags;
|
||||
|
||||
# Nix itself uses the `system` field of a derivation to decide where
|
||||
# to build it. This is a bit confusing for cross compilation.
|
||||
commonMeta = checkMeta.commonMeta hostPlatform;
|
||||
assertValidity = checkMeta.assertValidity hostPlatform;
|
||||
|
||||
/**
|
||||
This function creates a derivation, and returns it in the form of a [package attribute set](https://nix.dev/manual/nix/latest/glossary#package-attribute-set)
|
||||
that refers to the derivation's outputs.
|
||||
@@ -216,13 +224,6 @@ let
|
||||
*/
|
||||
mkDerivation = fnOrAttrs: makeDerivationExtensible (toFunction fnOrAttrs);
|
||||
|
||||
checkMeta = import ./check-meta.nix {
|
||||
inherit lib config;
|
||||
# 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) hostPlatform;
|
||||
};
|
||||
|
||||
# Based off lib.makeExtensible, with modifications:
|
||||
makeDerivationExtensible =
|
||||
rattrs:
|
||||
@@ -971,7 +972,7 @@ let
|
||||
}
|
||||
);
|
||||
|
||||
meta = checkMeta.commonMeta {
|
||||
meta = commonMeta {
|
||||
inherit validity attrs pos;
|
||||
references =
|
||||
attrs.nativeBuildInputs or [ ]
|
||||
@@ -979,7 +980,7 @@ let
|
||||
++ attrs.propagatedNativeBuildInputs or [ ]
|
||||
++ attrs.propagatedBuildInputs or [ ];
|
||||
};
|
||||
validity = checkMeta.assertValidity { inherit meta attrs; };
|
||||
validity = assertValidity { inherit meta attrs; };
|
||||
|
||||
checkedEnv =
|
||||
let
|
||||
|
||||
@@ -23,7 +23,7 @@ if minbootSupported then
|
||||
system = localSystem;
|
||||
inherit (config) rewriteURL;
|
||||
};
|
||||
checkMeta = callPackage ../generic/check-meta.nix { hostPlatform = localSystem; };
|
||||
checkMeta = callPackage ../generic/check-meta.nix { };
|
||||
}
|
||||
);
|
||||
compilerPackage =
|
||||
|
||||
@@ -8424,7 +8424,7 @@ with pkgs;
|
||||
inherit (stdenv.buildPlatform) system;
|
||||
inherit (config) rewriteURL;
|
||||
};
|
||||
checkMeta = callPackage ../stdenv/generic/check-meta.nix { inherit (stdenv) hostPlatform; };
|
||||
checkMeta = callPackage ../stdenv/generic/check-meta.nix { };
|
||||
}
|
||||
);
|
||||
minimal-bootstrap-sources =
|
||||
|
||||
Reference in New Issue
Block a user