forked from mirrors/nixpkgs
Elaborate localSystem
and crossSystem
in a consistent manner
This commit is contained in:
parent
d86caa3216
commit
3efc661a1d
|
@ -2,4 +2,22 @@ rec {
|
||||||
doubles = import ./doubles.nix;
|
doubles = import ./doubles.nix;
|
||||||
parse = import ./parse.nix;
|
parse = import ./parse.nix;
|
||||||
platforms = import ./platforms.nix;
|
platforms = import ./platforms.nix;
|
||||||
|
|
||||||
|
# Elaborate a `localSystem` or `crossSystem` so that it contains everything
|
||||||
|
# necessary.
|
||||||
|
#
|
||||||
|
# `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
|
||||||
|
final = {
|
||||||
|
# Prefer to parse `config` as it is strictly more informative.
|
||||||
|
parsed = parse.mkSystemFromString (if args ? config then args.config else args.system);
|
||||||
|
# Either of these can be losslessly-extracted from `parsed` iff parsing succeeds.
|
||||||
|
system = parse.doubleFromSystem final.parsed;
|
||||||
|
config = parse.tripleFromSystem final.parsed;
|
||||||
|
# Just a guess, based on `system`
|
||||||
|
platform = platforms.selectBySystem final.system;
|
||||||
|
} // args;
|
||||||
|
in final;
|
||||||
}
|
}
|
||||||
|
|
|
@ -474,7 +474,7 @@ rec {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
selectPlatformBySystem = system: {
|
selectBySystem = system: {
|
||||||
"i686-linux" = pc32;
|
"i686-linux" = pc32;
|
||||||
"x86_64-linux" = pc64;
|
"x86_64-linux" = pc64;
|
||||||
"armv5tel-linux" = sheevaplug;
|
"armv5tel-linux" = sheevaplug;
|
||||||
|
|
|
@ -40,6 +40,7 @@
|
||||||
|
|
||||||
let # Rename the function arguments
|
let # Rename the function arguments
|
||||||
configExpr = config;
|
configExpr = config;
|
||||||
|
crossSystem0 = crossSystem;
|
||||||
|
|
||||||
in let
|
in let
|
||||||
lib = import ../../lib;
|
lib = import ../../lib;
|
||||||
|
@ -52,12 +53,15 @@ in let
|
||||||
then configExpr { inherit pkgs; }
|
then configExpr { inherit pkgs; }
|
||||||
else configExpr;
|
else configExpr;
|
||||||
|
|
||||||
# Allow setting the platform in the config file. Otherwise, let's use a
|
# From a minimum of `system` or `config` (actually a target triple, *not*
|
||||||
# reasonable default.
|
# nixpkgs configuration), infer the other one and platform as needed.
|
||||||
localSystem =
|
localSystem = lib.systems.elaborate (
|
||||||
{ platform = lib.systems.platforms.selectPlatformBySystem args.localSystem.system; }
|
# Allow setting the platform in the config file. This take precedence over
|
||||||
// builtins.intersectAttrs { platform = null; } config
|
# the inferred platform, but not over an explicitly passed-in onw.
|
||||||
// args.localSystem;
|
builtins.intersectAttrs { platform = null; } config
|
||||||
|
// args.localSystem);
|
||||||
|
|
||||||
|
crossSystem = lib.mapNullable lib.systems.elaborate crossSystem0;
|
||||||
|
|
||||||
# A few packages make a new package set to draw their dependencies from.
|
# A few packages make a new package set to draw their dependencies from.
|
||||||
# (Currently to get a cross tool chain, or forced-i686 package.) Rather than
|
# (Currently to get a cross tool chain, or forced-i686 package.) Rather than
|
||||||
|
|
Loading…
Reference in a new issue