aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Helgesson <robert@rycee.net>2020-07-31 00:33:12 +0200
committerRobert Helgesson <robert@rycee.net>2020-08-19 00:33:25 +0200
commit9854342b9f088712ca3c5b67059fff5ec4f59182 (patch)
tree74d86bf1b86037de6ef3471324788a0acd02e4c1
parenta3dd580adc46628dd0c970037b6c87cff1251af5 (diff)
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
-rw-r--r--doc/release-notes/rl-2009.adoc7
-rw-r--r--modules/misc/nixpkgs.nix4
-rw-r--r--modules/modules.nix7
3 files changed, 15 insertions, 3 deletions
diff --git a/doc/release-notes/rl-2009.adoc b/doc/release-notes/rl-2009.adoc
index 7657033f105..7740646a961 100644
--- a/doc/release-notes/rl-2009.adoc
+++ b/doc/release-notes/rl-2009.adoc
@@ -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.
+
+* 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.
diff --git a/modules/misc/nixpkgs.nix b/modules/misc/nixpkgs.nix
index 7b0904a5f20..511dbec10b2 100644
--- a/modules/misc/nixpkgs.nix
+++ b/modules/misc/nixpkgs.nix
@@ -1,6 +1,6 @@
# Adapted from Nixpkgs.
-{ config, lib, pkgs, ... }:
+{ config, lib, pkgs, pkgsPath, ... }:
with lib;
@@ -49,7 +49,7 @@ let
merge = lib.mergeOneOption;
};
- _pkgs = import <nixpkgs> (
+ _pkgs = import pkgsPath (
filterAttrs (n: v: v != null) config.nixpkgs
);
diff --git a/modules/modules.nix b/modules/modules.nix
index 1744b4fd096..fa9c7f38cb7 100644
--- a/modules/modules.nix
+++ b/modules/modules.nix
@@ -197,9 +197,14 @@ let
modules = map (getAttr "file") (filter (getAttr "condition") allModules);
- pkgsModule = {
+ pkgsModule = { config, ... }: {
config = {
_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.check = check;
lib = lib.hm;