3
0
Fork 0
forked from mirrors/nixpkgs

systems: allow passing in string for cross/localSystem

This makes things a little bit more convenient. Just pass in like:

$ nix-build ’<nixpkgs>’ -A hello --argstr localSystem x86_64-linux --argstr crossSystem aarch64-linux
This commit is contained in:
Matthew Bauer 2019-06-04 11:10:03 -04:00
parent 40271ae138
commit 635b762569
3 changed files with 8 additions and 5 deletions

View file

@ -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);

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 {}
localSystem = if builtins.isString localSystem then localSystem
else (if args ? localSystem then {}
else { system = builtins.currentSystem; }) // localSystem;
})