From b5ffc6d7df8a117fdb4469dd21e1cefb38eef7fb Mon Sep 17 00:00:00 2001 From: Tobias Happ Date: Tue, 14 Dec 2021 20:37:07 +0100 Subject: [PATCH] home-manager: add extraSpecialArgs and sharedModules options --- modules/home-manager.nix | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/modules/home-manager.nix b/modules/home-manager.nix index ac9a5d0..c0b9267 100644 --- a/modules/home-manager.nix +++ b/modules/home-manager.nix @@ -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 specialArgs 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 pkgs argument in Home Manager. This disables the Home Manager