From 8cd4c31d6b8c6432986edf0ec5d00d2fe1c12854 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Wed, 8 Feb 2017 16:43:52 -0500 Subject: top-level: Allow nixpkgs to take localSystem directly This is instead of both system and platform, which is kind of ugly. --- pkgs/top-level/impure.nix | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'pkgs/top-level/impure.nix') diff --git a/pkgs/top-level/impure.nix b/pkgs/top-level/impure.nix index 6999b7428ba..98094e93160 100644 --- a/pkgs/top-level/impure.nix +++ b/pkgs/top-level/impure.nix @@ -12,9 +12,11 @@ let in -{ # Fallback: Assume we are building packages for the current (host, in GNU - # Autotools parlance) system. - system ? builtins.currentSystem +{ # We combine legacy `system` and `platform` into `localSystem`, if + # `localSystem` was not passed. Strictly speaking, this is pure desugar, but + # it is most convient to do so before the impure `localSystem.system` default, + # so we do it now. + localSystem ? builtins.intersectAttrs { system = null; platform = null; } args , # Fallback: The contents of the configuration file found at $NIXPKGS_CONFIG or # $HOME/.config/nixpkgs/config.nix. @@ -49,4 +51,13 @@ in , ... } @ args: -import ./. (args // { inherit system config overlays; }) +# If `localSystem` was explicitly passed, legacy `system` and `platform` should +# not be passed. +assert args ? localSystem -> !(args ? system || args ? platform); + +import ./. (builtins.removeAttrs args [ "system" "platform" ] // { + inherit config overlays; + # Fallback: Assume we are building packages on the current (build, in GNU + # Autotools parlance) system. + localSystem = { system = builtins.currentSystem; } // localSystem; +}) -- cgit 1.4.1