From a52e317200eca8ef7b8c6d6b77336a6a9f397a0e Mon Sep 17 00:00:00 2001 From: Matthew Bauer Date: Sat, 27 Apr 2019 20:37:42 -0400 Subject: check-meta: use system tuple in platforms Fixes #60345 --- lib/default.nix | 2 +- pkgs/stdenv/generic/check-meta.nix | 13 +++++-------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/lib/default.nix b/lib/default.nix index 8735b6476795..3efaaf0f8f9e 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -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 diff --git a/pkgs/stdenv/generic/check-meta.nix b/pkgs/stdenv/generic/check-meta.nix index 76e1c351ff40..33868c2e4ae6 100644 --- a/pkgs/stdenv/generic/check-meta.nix +++ b/pkgs/stdenv/generic/check-meta.nix @@ -168,7 +168,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 @@ -209,11 +209,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" ]; @@ -235,8 +230,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 -- cgit v1.2.3 From e500bb84090ddca3e213f4d6ced1f1647be486d6 Mon Sep 17 00:00:00 2001 From: Matthew Bauer Date: Tue, 30 Apr 2019 11:50:45 -0400 Subject: systems: add riscv double This was never listed in doubles.nix! Not sure why? --- lib/systems/doubles.nix | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/systems/doubles.nix b/lib/systems/doubles.nix index c6877ebef0bc..ff071c182d4f 100644 --- a/lib/systems/doubles.nix +++ b/lib/systems/doubles.nix @@ -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; -- cgit v1.2.3 From accfd7ca0832dd7c3b4568f7835d2637910be99b Mon Sep 17 00:00:00 2001 From: Matthew Bauer Date: Tue, 30 Apr 2019 17:43:52 -0400 Subject: unix-tools: get platforms from doubles --- pkgs/top-level/unix-tools.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/top-level/unix-tools.nix b/pkgs/top-level/unix-tools.nix index 00edb7c09072..beb2a996a5ef 100644 --- a/pkgs/top-level/unix-tools.nix +++ b/pkgs/top-level/unix-tools.nix @@ -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; -- cgit v1.2.3 From 40271ae1382b14673b7b3f9edb6c1f9bba1bbe47 Mon Sep 17 00:00:00 2001 From: Matthew Bauer Date: Tue, 4 Jun 2019 11:09:43 -0400 Subject: systems: remove forMeta This is unused now. --- lib/systems/default.nix | 1 - lib/systems/for-meta.nix | 38 -------------------------------------- 2 files changed, 39 deletions(-) delete mode 100644 lib/systems/for-meta.nix diff --git a/lib/systems/default.nix b/lib/systems/default.nix index 5e6d277be7d5..ea18904cc635 100644 --- a/lib/systems/default.nix +++ b/lib/systems/default.nix @@ -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; }; diff --git a/lib/systems/for-meta.nix b/lib/systems/for-meta.nix deleted file mode 100644 index 17ae94deb7d1..000000000000 --- a/lib/systems/for-meta.nix +++ /dev/null @@ -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; -} -- cgit v1.2.3 From 635b7625690d9f8f61da0a187e7ed4a7ec274fdc Mon Sep 17 00:00:00 2001 From: Matthew Bauer Date: Tue, 4 Jun 2019 11:10:03 -0400 Subject: systems: allow passing in string for cross/localSystem MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This makes things a little bit more convenient. Just pass in like: $ nix-build ’’ -A hello --argstr localSystem x86_64-linux --argstr crossSystem aarch64-linux --- lib/systems/default.nix | 4 +++- pkgs/top-level/default.nix | 4 ++-- pkgs/top-level/impure.nix | 5 +++-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/systems/default.nix b/lib/systems/default.nix index ea18904cc635..8aa413f53817 100644 --- a/lib/systems/default.nix +++ b/lib/systems/default.nix @@ -14,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); diff --git a/pkgs/top-level/default.nix b/pkgs/top-level/default.nix index b6de076a570c..904ef8d39796 100644 --- a/pkgs/top-level/default.nix +++ b/pkgs/top-level/default.nix @@ -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; diff --git a/pkgs/top-level/impure.nix b/pkgs/top-level/impure.nix index da288f15d2e2..3ba6c08a140b 100644 --- a/pkgs/top-level/impure.nix +++ b/pkgs/top-level/impure.nix @@ -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; }) -- cgit v1.2.3