1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-23 03:29:45 +01:00

nixos integration: add option 'useGlobalPkgs'

PR #1059
This commit is contained in:
Erik Arvstedt 2020-03-01 17:06:20 +01:00 committed by Robert Helgesson
parent c7b43786ad
commit efbe1383e6
No known key found for this signature in database
GPG key ID: 36BDAA14C2797E89
4 changed files with 51 additions and 6 deletions

View file

@ -225,6 +225,23 @@ home-manager.useUserPackages = true;
become the default value in the future. become the default value in the future.
</para> </para>
</note> </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>
<section xml:id="sec-install-nix-darwin-module"> <section xml:id="sec-install-nix-darwin-module">
<title>nix-darwin module</title> <title>nix-darwin module</title>

View file

@ -1351,6 +1351,21 @@ in
'--description', '--on-event', and more. '--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
'';
}
]; ];
}; };
} }

View file

@ -5,6 +5,9 @@
# Whether to enable module type checking. # Whether to enable module type checking.
, check ? true , check ? true
# If disabled, the pkgs attribute passed to this function is used instead.
, useNixpkgsModule ? true
}: }:
with lib; with lib;
@ -27,7 +30,7 @@ let
(loadModule ./misc/gtk.nix { }) (loadModule ./misc/gtk.nix { })
(loadModule ./misc/lib.nix { }) (loadModule ./misc/lib.nix { })
(loadModule ./misc/news.nix { }) (loadModule ./misc/news.nix { })
(loadModule ./misc/nixpkgs.nix { }) (loadModule ./misc/nixpkgs.nix { condition = useNixpkgsModule; })
(loadModule ./misc/numlock.nix { condition = hostPlatform.isLinux; }) (loadModule ./misc/numlock.nix { condition = hostPlatform.isLinux; })
(loadModule ./misc/pam.nix { }) (loadModule ./misc/pam.nix { })
(loadModule ./misc/qt.nix { }) (loadModule ./misc/qt.nix { })
@ -170,11 +173,14 @@ let
modules = map (getAttr "file") (filter (getAttr "condition") allModules); modules = map (getAttr "file") (filter (getAttr "condition") allModules);
pkgsModule = { pkgsModule = {
config._module.args.baseModules = modules; config = {
config._module.args.pkgs = lib.mkDefault pkgs; _module.args.baseModules = modules;
config._module.check = check; _module.args.pkgs = lib.mkDefault pkgs;
config.lib = lib.hm; _module.check = check;
config.nixpkgs.system = mkDefault pkgs.system; lib = lib.hm;
} // optionalAttrs useNixpkgsModule {
nixpkgs.system = mkDefault pkgs.system;
};
}; };
in in

View file

@ -15,6 +15,7 @@ let
imports = import ../modules/modules.nix { imports = import ../modules/modules.nix {
inherit pkgs; inherit pkgs;
lib = extendedLib; lib = extendedLib;
useNixpkgsModule = !cfg.useGlobalPkgs;
}; };
config = { config = {
@ -45,6 +46,12 @@ in {
<option>users.users.name?.packages</option> option. <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 { backupFileExtension = mkOption {
type = types.nullOr types.str; type = types.nullOr types.str;
default = null; default = null;