···11/* This function composes the Nix Packages collection. It:
2233- 1. Applies the final stage to the given `config` if it is a function
33+ 1. Elaborates `localSystem` and `crossSystem` with defaults as needed.
4455- 2. Infers an appropriate `platform` based on the `system` if none is
66- provided
55+ 2. Applies the final stage to the given `config` if it is a function
7687 3. Defaults to no non-standard config and no cross-compilation target
98···5049in let
5150 lib = import ../../lib;
52515252+ localSystem = lib.systems.elaborate args.localSystem;
5353+5454+ # Condition preserves sharing which in turn affects equality.
5555+ crossSystem =
5656+ if crossSystem0 == null || crossSystem0 == args.localSystem
5757+ then localSystem
5858+ else lib.systems.elaborate crossSystem0;
5959+5360 # Allow both:
5461 # { /* the config */ } and
5562 # { pkgs, ... } : { /* the config */ }
···5764 if lib.isFunction config0
5865 then config0 { inherit pkgs; }
5966 else config0;
6060-6161- # From a minimum of `system` or `config` (actually a target triple, *not*
6262- # nixpkgs configuration), infer the other one and platform as needed.
6363- localSystem = lib.systems.elaborate (if builtins.isAttrs args.localSystem then (
6464- # Allow setting the platform in the config file. This take precedence over
6565- # the inferred platform, but not over an explicitly passed-in one.
6666- builtins.intersectAttrs { platform = null; } config1
6767- // args.localSystem) else args.localSystem);
6868-6969- crossSystem = if crossSystem0 == null then localSystem
7070- else lib.systems.elaborate crossSystem0;
71677268 configEval = lib.evalModules {
7369 modules = [
+14-20
pkgs/top-level/impure.nix
···12121313in
14141515-{ # We combine legacy `system` and `platform` into `localSystem`, if
1616- # `localSystem` was not passed. Strictly speaking, this is pure desugar, but
1717- # it is most convient to do so before the impure `localSystem.system` default,
1818- # so we do it now.
1919- localSystem ? builtins.intersectAttrs { system = null; platform = null; } args
1515+{ # We put legacy `system` into `localSystem`, if `localSystem` was not passed.
1616+ # If neither is passed, assume we are building packages on the current
1717+ # (build, in GNU Autotools parlance) platform.
1818+ localSystem ? { system = args.system or builtins.currentSystem; }
20192121-, # These are needed only because nix's `--arg` command-line logic doesn't work
2222- # with unnamed parameters allowed by ...
2323- system ? localSystem.system
2424-, platform ? localSystem.platform
2525-, crossSystem ? null
2020+# These are needed only because nix's `--arg` command-line logic doesn't work
2121+# with unnamed parameters allowed by ...
2222+, system ? localSystem.system
2323+, crossSystem ? localSystem
26242725, # Fallback: The contents of the configuration file found at $NIXPKGS_CONFIG or
2826 # $HOME/.config/nixpkgs/config.nix.
···7775, ...
7876} @ args:
79778080-# If `localSystem` was explicitly passed, legacy `system` and `platform` should
8181-# not be passed.
8282-assert args ? localSystem -> !(args ? system || args ? platform);
7878+# If `localSystem` was explicitly passed, legacy `system` should
7979+# not be passed, and vice-versa.
8080+assert args ? localSystem -> !(args ? system);
8181+assert args ? system -> !(args ? localSystem);
83828484-import ./. (builtins.removeAttrs args [ "system" "platform" ] // {
8585- inherit config overlays crossSystem crossOverlays;
8686- # Fallback: Assume we are building packages on the current (build, in GNU
8787- # Autotools parlance) system.
8888- localSystem = if builtins.isString localSystem then localSystem
8989- else (if args ? localSystem then {}
9090- else { system = builtins.currentSystem; }) // localSystem;
8383+import ./. (builtins.removeAttrs args [ "system" ] // {
8484+ inherit config overlays localSystem;
9185})