diff options
author | John Ericson <Ericson2314@Yahoo.com> | 2016-04-26 10:53:31 -0700 |
---|---|---|
committer | John Ericson <Ericson2314@Yahoo.com> | 2016-07-14 14:33:23 -0700 |
commit | 4af2bf66631d187d952b70fba4963e33002d1dcb (patch) | |
tree | f1750f69a1519370f0ef7761fc66f9dbfd682982 | |
parent | 18a91ddfb66f2f3f706b93a874152a428874d346 (diff) | |
download | nixlib-4af2bf66631d187d952b70fba4963e33002d1dcb.tar nixlib-4af2bf66631d187d952b70fba4963e33002d1dcb.tar.gz nixlib-4af2bf66631d187d952b70fba4963e33002d1dcb.tar.bz2 nixlib-4af2bf66631d187d952b70fba4963e33002d1dcb.tar.lz nixlib-4af2bf66631d187d952b70fba4963e33002d1dcb.tar.xz nixlib-4af2bf66631d187d952b70fba4963e33002d1dcb.tar.zst nixlib-4af2bf66631d187d952b70fba4963e33002d1dcb.zip |
Separate fix-point from config importing hacks and other impurities
-rw-r--r-- | default.nix | 2 | ||||
-rw-r--r-- | pkgs/top-level/default.nix | 19 | ||||
-rw-r--r-- | pkgs/top-level/impure.nix | 24 |
3 files changed, 28 insertions, 17 deletions
diff --git a/default.nix b/default.nix index c384a5bb6946..8171f4149d2f 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 8913dc1ef59e..87813571d9aa 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 000000000000..e90668159279 --- /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; }) |