summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--default.nix2
-rw-r--r--pkgs/top-level/default.nix19
-rw-r--r--pkgs/top-level/impure.nix24
3 files changed, 28 insertions, 17 deletions
diff --git a/default.nix b/default.nix
index c384a5bb694..8171f4149d2 100644
--- a/default.nix
+++ b/default.nix
@@ -6,4 +6,4 @@ if ! builtins ? nixVersion || builtins.compareVersions requiredVersion builtins.
 
 else
 
-  import ./pkgs/top-level
+  import ./pkgs/top-level/impure.nix
diff --git a/pkgs/top-level/default.nix b/pkgs/top-level/default.nix
index 8913dc1ef59..87813571d9a 100644
--- a/pkgs/top-level/default.nix
+++ b/pkgs/top-level/default.nix
@@ -6,7 +6,7 @@
 
 
 { # The system (e.g., `i686-linux') for which to build the packages.
-  system ? builtins.currentSystem
+  system
 
 , # The standard environment to use.  Only used for bootstrapping.  If
   # null, the default standard environment is used.
@@ -19,21 +19,8 @@
                && system != "x86_64-solaris"
                && system != "x86_64-kfreebsd-gnu")
 
-, # Allow a configuration attribute set to be passed in as an
-  # argument.  Otherwise, it's read from $NIXPKGS_CONFIG or
-  # ~/.nixpkgs/config.nix.
-  #
-  # [For NixOS (nixos-rebuild), use nixpkgs.config option to set.]
-  config ? let
-      inherit (builtins) getEnv pathExists;
-
-      configFile = getEnv "NIXPKGS_CONFIG";
-      homeDir = getEnv "HOME";
-      configFile2 = homeDir + "/.nixpkgs/config.nix";
-    in
-      if configFile != "" && pathExists configFile then import configFile
-      else if homeDir != "" && pathExists configFile2 then import configFile2
-      else {}
+, # Allow a configuration attribute set to be passed in as an argument.
+  config ? {}
 
 , crossSystem ? null
 , platform ? null
diff --git a/pkgs/top-level/impure.nix b/pkgs/top-level/impure.nix
new file mode 100644
index 00000000000..e9066815927
--- /dev/null
+++ b/pkgs/top-level/impure.nix
@@ -0,0 +1,24 @@
+/* Impure default args for `pkgs/top-level/default.nix`. See that file
+   for the meaning of each argument. */
+
+{ # Fallback: Assume we are building packages for the current (host, in GNU
+  # Autotools parlance) system.
+  system ? builtins.currentSystem
+
+, # Fallback: The contents of the configuration file found at $NIXPKGS_CONFIG or
+  # $HOME/.nixpkgs/config.nix.
+  config ? let
+      inherit (builtins) getEnv pathExists;
+
+      configFile = getEnv "NIXPKGS_CONFIG";
+      homeDir = getEnv "HOME";
+      configFile2 = homeDir + "/.nixpkgs/config.nix";
+    in
+      if configFile != "" && pathExists configFile then import configFile
+      else if homeDir != "" && pathExists configFile2 then import configFile2
+      else {}
+
+, ...
+} @ args:
+
+import ./. (args // { inherit system config; })