3
0
Fork 0
forked from mirrors/nixpkgs

Merge pull request #60349 from matthewbauer/fix-60345

check-meta: use system tuple in platforms
This commit is contained in:
Matthew Bauer 2019-06-04 11:29:48 -04:00 committed by GitHub
commit 760c9995b0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 18 additions and 54 deletions

View file

@ -50,7 +50,7 @@ let
filesystem = callLibs ./filesystem.nix;
# back-compat aliases
platforms = systems.forMeta;
platforms = systems.doubles;
inherit (builtins) add addErrorContext attrNames concatLists
deepSeq elem elemAt filter genericClosure genList getAttr

View file

@ -3,7 +3,6 @@
rec {
doubles = import ./doubles.nix { inherit lib; };
forMeta = import ./for-meta.nix { inherit lib; };
parse = import ./parse.nix { inherit lib; };
inspect = import ./inspect.nix { inherit lib; };
platforms = import ./platforms.nix { inherit lib; };
@ -15,7 +14,9 @@ rec {
# `parsed` is inferred from args, both because there are two options with one
# clearly prefered, and to prevent cycles. A simpler fixed point where the RHS
# always just used `final.*` would fail on both counts.
elaborate = args: let
elaborate = args': let
args = if lib.isString args' then { system = args'; }
else args';
final = {
# Prefer to parse `config` as it is strictly more informative.
parsed = parse.mkSystemFromString (if args ? config then args.config else args.system);

View file

@ -19,6 +19,8 @@ let
"x86_64-windows" "i686-windows"
"wasm64-wasi" "wasm32-wasi"
"riscv32-linux" "riscv64-linux"
];
allParsed = map parse.mkSystemFromString all;
@ -36,6 +38,7 @@ in rec {
i686 = filterDoubles predicates.isi686;
x86_64 = filterDoubles predicates.isx86_64;
mips = filterDoubles predicates.isMips;
riscv = filterDoubles predicates.isRiscV;
cygwin = filterDoubles predicates.isCygwin;
darwin = filterDoubles predicates.isDarwin;

View file

@ -1,38 +0,0 @@
{ lib }:
let
inherit (lib.systems) parse;
inherit (lib.systems.inspect) patterns;
abis = lib.mapAttrs (_: abi: builtins.removeAttrs abi [ "assertions" ]) parse.abis;
in rec {
all = [ {} ]; # `{}` matches anything
none = [];
arm = [ patterns.isAarch32 ];
aarch64 = [ patterns.isAarch64 ];
x86 = [ patterns.isx86 ];
i686 = [ patterns.isi686 ];
x86_64 = [ patterns.isx86_64 ];
mips = [ patterns.isMips ];
riscv = [ patterns.isRiscV ];
cygwin = [ patterns.isCygwin ];
darwin = [ patterns.isDarwin ];
freebsd = [ patterns.isFreeBSD ];
# Should be better, but MinGW is unclear.
gnu = [
{ kernel = parse.kernels.linux; abi = abis.gnu; }
{ kernel = parse.kernels.linux; abi = abis.gnueabi; }
{ kernel = parse.kernels.linux; abi = abis.gnueabihf; }
];
illumos = [ patterns.isSunOS ];
linux = [ patterns.isLinux ];
netbsd = [ patterns.isNetBSD ];
openbsd = [ patterns.isOpenBSD ];
unix = patterns.isUnix; # Actually a list
windows = [ patterns.isWindows ];
wasi = [ patterns.isWasi ];
inherit (lib.systems.doubles) mesaPlatforms;
}

View file

@ -169,7 +169,7 @@ let
license = either (listOf lib.types.attrs) (either lib.types.attrs str);
maintainers = listOf (attrsOf str);
priority = int;
platforms = listOf (either str lib.systems.parsedPlatform.types.system);
platforms = listOf str;
hydraPlatforms = listOf str;
broken = bool;
# TODO: refactor once something like Profpatsch's types-simple will land
@ -210,11 +210,6 @@ let
else "key '${k}' is unrecognized; expected one of: \n\t [${lib.concatMapStringsSep ", " (x: "'${x}'") (lib.attrNames metaTypes)}]";
checkMeta = meta: if shouldCheckMeta then lib.remove null (lib.mapAttrsToList checkMetaAttr meta) else [];
checkPlatform = attrs: let
anyMatch = lib.any (lib.meta.platformMatch hostPlatform);
in anyMatch (attrs.meta.platforms or lib.platforms.all) &&
! anyMatch (attrs.meta.badPlatforms or []);
checkOutputsToInstall = attrs: let
expectedOutputs = attrs.meta.outputsToInstall or [];
actualOutputs = attrs.outputs or [ "out" ];
@ -236,8 +231,10 @@ let
{ valid = false; reason = "blacklisted"; errormsg = "has a blacklisted license (${showLicense attrs.meta.license})"; }
else if !allowBroken && attrs.meta.broken or false then
{ valid = false; reason = "broken"; errormsg = "is marked as broken"; }
else if !allowUnsupportedSystem && !(checkPlatform attrs) then
{ valid = false; reason = "unsupported"; errormsg = "is not supported on ${hostPlatform.config}"; }
else if !allowUnsupportedSystem &&
(!lib.lists.elem hostPlatform.system (attrs.meta.platforms or lib.platforms.all) ||
lib.lists.elem hostPlatform.system (attrs.meta.badPlatforms or [])) then
{ valid = false; reason = "unsupported"; errormsg = "is not supported on ${hostPlatform.system}"; }
else if !(hasAllowedInsecure attrs) then
{ valid = false; reason = "insecure"; errormsg = "is marked as insecure"; }
else if checkOutputsToInstall attrs then

View file

@ -57,11 +57,11 @@ in let
# From a minimum of `system` or `config` (actually a target triple, *not*
# nixpkgs configuration), infer the other one and platform as needed.
localSystem = lib.systems.elaborate (
localSystem = lib.systems.elaborate (if builtins.isAttrs args.localSystem then (
# Allow setting the platform in the config file. This take precedence over
# the inferred platform, but not over an explicitly passed-in one.
builtins.intersectAttrs { platform = null; } config1
// args.localSystem);
// args.localSystem) else args.localSystem);
crossSystem = if crossSystem0 == null then localSystem
else lib.systems.elaborate crossSystem0;

View file

@ -85,6 +85,7 @@ import ./. (builtins.removeAttrs args [ "system" "platform" ] // {
inherit config overlays crossSystem crossOverlays;
# Fallback: Assume we are building packages on the current (build, in GNU
# Autotools parlance) system.
localSystem = (if args ? localSystem then {}
else { system = builtins.currentSystem; }) // localSystem;
localSystem = if builtins.isString localSystem then localSystem
else (if args ? localSystem then {}
else { system = builtins.currentSystem; }) // localSystem;
})

View file

@ -22,7 +22,7 @@ let
in runCommand "${cmd}-${version}" {
meta = {
priority = 10;
platforms = map (n: { kernel.name = n; }) (attrNames providers);
platforms = lib.platforms.${stdenv.hostPlatform.parsed.kernel.name} or lib.platforms.all;
};
passthru = { inherit provider; };
preferLocalBuild = true;