home-manager: add extraSpecialArgs and sharedModules options

This commit is contained in:
Tobias Happ 2021-12-14 20:37:07 +01:00
parent 38241f6363
commit b5ffc6d7df

View file

@ -10,7 +10,7 @@ let
extendedLib = import (home-manager-path + "/modules/lib/stdlib-extended.nix") pkgs.lib;
hmModule = types.submoduleWith {
specialArgs = { lib = extendedLib; };
specialArgs = { lib = extendedLib; } // cfg.extraSpecialArgs;
modules = [
({ name, ... }: {
imports = import (home-manager-path + "/modules/modules.nix") {
@ -27,7 +27,7 @@ let
home.homeDirectory = config.user.home;
};
})
];
] ++ cfg.sharedModules;
};
in
@ -54,6 +54,32 @@ in
description = "Home Manager configuration.";
};
extraSpecialArgs = mkOption {
type = types.attrs;
default = { };
example = literalExpression "{ inherit emacs-overlay; }";
description = ''
Extra <literal>specialArgs</literal> passed to Home Manager. This
option can be used to pass additional arguments to all modules.
'';
};
sharedModules = mkOption {
type = with types;
# TODO: use types.raw once this PR is merged: https://github.com/NixOS/nixpkgs/pull/132448
listOf (mkOptionType {
name = "submodule";
inherit (submodule { }) check;
merge = lib.options.mergeOneOption;
description = "Home Manager modules";
});
default = [ ];
example = literalExpression "[ { home.packages = [ nixpkgs-fmt ]; } ]";
description = ''
Extra modules.
'';
};
useGlobalPkgs = mkEnableOption ''
using the system configuration's <literal>pkgs</literal>
argument in Home Manager. This disables the Home Manager