aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/installation.xml17
-rw-r--r--modules/misc/news.nix15
-rw-r--r--modules/modules.nix18
-rw-r--r--nixos/default.nix7
4 files changed, 51 insertions, 6 deletions
diff --git a/doc/installation.xml b/doc/installation.xml
index 52119886800..9c5d24b3d92 100644
--- a/doc/installation.xml
+++ b/doc/installation.xml
@@ -225,6 +225,23 @@ home-manager.useUserPackages = true;
become the default value in the future.
</para>
</note>
+
+ <note>
+ <para>
+ By default, Home Manager uses a private <literal>pkgs</literal> instance
+ that is configured via the <option>home-manager.users.&lt;name&gt;.nixpkgs</option> options.
+ To instead use the global <literal>pkgs</literal> that is configured via
+ the system level <option>nixpkgs</option> options, set
+ </para>
+<programlisting language="nix">
+home-manager.useGlobalPkgs = true;
+</programlisting>
+ <para>
+ This saves an extra Nixpkgs evaluation, adds consistency, and removes the
+ dependency on <envar>NIX_PATH</envar>, which is otherwise used for
+ importing Nixpkgs.
+ </para>
+ </note>
</section>
<section xml:id="sec-install-nix-darwin-module">
<title>nix-darwin module</title>
diff --git a/modules/misc/news.nix b/modules/misc/news.nix
index 0f0c2ac1674..cc2892e87b7 100644
--- a/modules/misc/news.nix
+++ b/modules/misc/news.nix
@@ -1351,6 +1351,21 @@ in
'--description', '--on-event', and more.
'';
}
+
+ {
+ time = "2020-03-07T13:11:43+00:00";
+ condition = hostPlatform.isLinux;
+ message = ''
+ The NixOS module has a new option: 'home-manager.useGlobalPkgs'.
+
+ This enables using the system configuration's 'pkgs'
+ argument in Home Manager.
+
+ To learn more, see the installation section of the manual
+
+ https://rycee.gitlab.io/home-manager/#sec-install-nixos-module
+ '';
+ }
];
};
}
diff --git a/modules/modules.nix b/modules/modules.nix
index 9d741016fbe..263c1176cc6 100644
--- a/modules/modules.nix
+++ b/modules/modules.nix
@@ -5,6 +5,9 @@
# Whether to enable module type checking.
, check ? true
+
+# If disabled, the pkgs attribute passed to this function is used instead.
+, useNixpkgsModule ? true
}:
with lib;
@@ -27,7 +30,7 @@ let
(loadModule ./misc/gtk.nix { })
(loadModule ./misc/lib.nix { })
(loadModule ./misc/news.nix { })
- (loadModule ./misc/nixpkgs.nix { })
+ (loadModule ./misc/nixpkgs.nix { condition = useNixpkgsModule; })
(loadModule ./misc/numlock.nix { condition = hostPlatform.isLinux; })
(loadModule ./misc/pam.nix { })
(loadModule ./misc/qt.nix { })
@@ -170,11 +173,14 @@ let
modules = map (getAttr "file") (filter (getAttr "condition") allModules);
pkgsModule = {
- config._module.args.baseModules = modules;
- config._module.args.pkgs = lib.mkDefault pkgs;
- config._module.check = check;
- config.lib = lib.hm;
- config.nixpkgs.system = mkDefault pkgs.system;
+ config = {
+ _module.args.baseModules = modules;
+ _module.args.pkgs = lib.mkDefault pkgs;
+ _module.check = check;
+ lib = lib.hm;
+ } // optionalAttrs useNixpkgsModule {
+ nixpkgs.system = mkDefault pkgs.system;
+ };
};
in
diff --git a/nixos/default.nix b/nixos/default.nix
index f4e417bda71..4f7f18683ed 100644
--- a/nixos/default.nix
+++ b/nixos/default.nix
@@ -15,6 +15,7 @@ let
imports = import ../modules/modules.nix {
inherit pkgs;
lib = extendedLib;
+ useNixpkgsModule = !cfg.useGlobalPkgs;
};
config = {
@@ -45,6 +46,12 @@ in {
<option>users.users.‹name?›.packages</option> option.
'';
+ useGlobalPkgs = mkEnableOption ''
+ using the system configuration's <literal>pkgs</literal>
+ argument in Home Manager. This disables the Home Manager
+ options <option>nixpkgs.*</option>
+ '';
+
backupFileExtension = mkOption {
type = types.nullOr types.str;
default = null;