1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-27 05:29:46 +01:00

nixpkgs: take Nixpkgs path from argument

This removes the dependency on the `nixpkgs` channel within the
modules for state version ≥ 20.09. The default Nixpkgs source starting
from this state version is the path of the `pkgs` argument used to
bootstrap the Home Manager modeuls.

This is a prerequisite for using Home Manager withing Nix flakes.

PR #1420
This commit is contained in:
Robert Helgesson 2020-07-31 00:33:12 +02:00
parent a3dd580adc
commit 9854342b9f
No known key found for this signature in database
GPG key ID: 36BDAA14C2797E89
3 changed files with 15 additions and 3 deletions

View file

@ -45,3 +45,10 @@ will automatically include these options, when necessary.
-- --
* Git's `smtpEncryption` option is now set to `tls` only if both <<opt-accounts.email.accounts.\_name_.smtp.tls.enable>> and <<opt-accounts.email.accounts.\_name_.smtp.tls.useStartTls>> are `true`. If only <<opt-accounts.email.accounts.\_name_.smtp.tls.enable>> is `true`, `ssl` is used instead. * Git's `smtpEncryption` option is now set to `tls` only if both <<opt-accounts.email.accounts.\_name_.smtp.tls.enable>> and <<opt-accounts.email.accounts.\_name_.smtp.tls.useStartTls>> are `true`. If only <<opt-accounts.email.accounts.\_name_.smtp.tls.enable>> is `true`, `ssl` is used instead.
* The `nixpkgs` module no longer references `<nixpkgs>`. Before it would do so when building the `pkgs` module argument. Starting with state version 20.09, the `pkgs` argument is instead built from the same Nixpkgs that was used to initialize the Home Manager modules. This is useful, for example, when using Home Manager within a Nix Flake. If you want to keep using `<nixpkgs>` with state version ≥ 20.09 then add
+
[source,nix]
_module.args.pkgsPath = <nixpkgs>;
+
to your Home Manager configuration.

View file

@ -1,6 +1,6 @@
# Adapted from Nixpkgs. # Adapted from Nixpkgs.
{ config, lib, pkgs, ... }: { config, lib, pkgs, pkgsPath, ... }:
with lib; with lib;
@ -49,7 +49,7 @@ let
merge = lib.mergeOneOption; merge = lib.mergeOneOption;
}; };
_pkgs = import <nixpkgs> ( _pkgs = import pkgsPath (
filterAttrs (n: v: v != null) config.nixpkgs filterAttrs (n: v: v != null) config.nixpkgs
); );

View file

@ -197,9 +197,14 @@ let
modules = map (getAttr "file") (filter (getAttr "condition") allModules); modules = map (getAttr "file") (filter (getAttr "condition") allModules);
pkgsModule = { pkgsModule = { config, ... }: {
config = { config = {
_module.args.baseModules = modules; _module.args.baseModules = modules;
_module.args.pkgsPath = lib.mkDefault (
if versionAtLeast config.home.stateVersion "20.09" then
pkgs.path
else
<nixpkgs>);
_module.args.pkgs = lib.mkDefault pkgs; _module.args.pkgs = lib.mkDefault pkgs;
_module.check = check; _module.check = check;
lib = lib.hm; lib = lib.hm;