1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-26 21:19:45 +01:00

flake: add extraModules option, inherit nixpkgs config and overlays in homeManagerConfiguration (#1767)

* flake: ensure passed pkgs with overlays and config is used

In the pkgsModule inside modules/modules.nix it will try to use the
<nixpkgs> from NIX_PATH if home.stateVersion is not set. This is not
available when using flakes so we need to require at least 20.09 and we
might as well default to that.

Also if you have added overlays and config to your pkgs it will be lost
so we need to transfer those as well.

This is an alternative to passing pkgs to extraSpecialArgs which will
break the usage of things like nixpkgs.config.packageOverrides.

* flake: add extraModules

If you want to add some extra home-manager modules, you have to mix them
with the configuration as such:

configuration = {
  imports = [
    emacs-config.homeManagerModules.emacsConfig
    ./home.nix
  ];
};

Instead of:
configuration = ./home.nix;
extraModules = [ emacs-config.homeManagerModules.emacsConfig ];

Which separates these two concerns.
This commit is contained in:
Terje Larsen 2021-04-20 22:19:24 +02:00 committed by GitHub
parent 1e7e8ac75d
commit 0c236e13bc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -28,14 +28,17 @@
lib = { lib = {
hm = import ./modules/lib { lib = nixpkgs.lib; }; hm = import ./modules/lib { lib = nixpkgs.lib; };
homeManagerConfiguration = { configuration, system, homeDirectory homeManagerConfiguration = { configuration, system, homeDirectory
, username, extraSpecialArgs ? { } , username, extraModules ? [ ], extraSpecialArgs ? { }
, pkgs ? builtins.getAttr system nixpkgs.outputs.legacyPackages , pkgs ? builtins.getAttr system nixpkgs.outputs.legacyPackages
, check ? true }@args: , check ? true, stateVersion ? "20.09" }@args:
assert nixpkgs.lib.versionAtLeast stateVersion "20.09";
import ./modules { import ./modules {
inherit pkgs check extraSpecialArgs; inherit pkgs check extraSpecialArgs;
configuration = { ... }: { configuration = { ... }: {
imports = [ configuration ]; imports = [ configuration ] ++ extraModules;
home = { inherit homeDirectory username; }; home = { inherit homeDirectory stateVersion username; };
nixpkgs = { inherit (pkgs) config overlays; };
}; };
}; };
}; };