1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-26 21:19: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.
</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>

View file

@ -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
'';
}
];
};
}

View file

@ -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

View file

@ -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;