summary refs log tree commit diff
path: root/pkgs/top-level/impure.nix
diff options
context:
space:
mode:
authorJohn Ericson <Ericson2314@Yahoo.com>2016-04-26 10:53:31 -0700
committerJohn Ericson <Ericson2314@Yahoo.com>2016-07-14 14:33:23 -0700
commit4af2bf66631d187d952b70fba4963e33002d1dcb (patch)
treef1750f69a1519370f0ef7761fc66f9dbfd682982 /pkgs/top-level/impure.nix
parent18a91ddfb66f2f3f706b93a874152a428874d346 (diff)
downloadnixpkgs-4af2bf66631d187d952b70fba4963e33002d1dcb.tar
nixpkgs-4af2bf66631d187d952b70fba4963e33002d1dcb.tar.gz
nixpkgs-4af2bf66631d187d952b70fba4963e33002d1dcb.tar.bz2
nixpkgs-4af2bf66631d187d952b70fba4963e33002d1dcb.tar.lz
nixpkgs-4af2bf66631d187d952b70fba4963e33002d1dcb.tar.xz
nixpkgs-4af2bf66631d187d952b70fba4963e33002d1dcb.tar.zst
nixpkgs-4af2bf66631d187d952b70fba4963e33002d1dcb.zip
Separate fix-point from config importing hacks and other impurities
Diffstat (limited to 'pkgs/top-level/impure.nix')
-rw-r--r--pkgs/top-level/impure.nix24
1 files changed, 24 insertions, 0 deletions
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; })