From 9854342b9f088712ca3c5b67059fff5ec4f59182 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Fri, 31 Jul 2020 00:33:12 +0200 Subject: [PATCH] nixpkgs: take Nixpkgs path from argument MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- doc/release-notes/rl-2009.adoc | 7 +++++++ modules/misc/nixpkgs.nix | 4 ++-- modules/modules.nix | 7 ++++++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/doc/release-notes/rl-2009.adoc b/doc/release-notes/rl-2009.adoc index 7657033f..7740646a 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 <> and <> are `true`. If only <> is `true`, `ssl` is used instead. + +* The `nixpkgs` module no longer references ``. 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 `` with state version ≥ 20.09 then add ++ +[source,nix] +_module.args.pkgsPath = ; ++ +to your Home Manager configuration. diff --git a/modules/misc/nixpkgs.nix b/modules/misc/nixpkgs.nix index 7b0904a5..511dbec1 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 ( + _pkgs = import pkgsPath ( filterAttrs (n: v: v != null) config.nixpkgs ); diff --git a/modules/modules.nix b/modules/modules.nix index 1744b4fd..fa9c7f38 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 + ); _module.args.pkgs = lib.mkDefault pkgs; _module.check = check; lib = lib.hm;