diff --git a/nix-darwin/default.nix b/nix-darwin/default.nix
index 956695926..c529ca4a1 100644
--- a/nix-darwin/default.nix
+++ b/nix-darwin/default.nix
@@ -9,7 +9,10 @@ let
extendedLib = import ../modules/lib/stdlib-extended.nix pkgs.lib;
hmModule = types.submoduleWith {
- specialArgs = { lib = extendedLib; };
+ specialArgs = {
+ lib = extendedLib;
+ darwinConfig = config;
+ } // cfg.extraSpecialArgs;
modules = [
({ name, ... }: {
imports = import ../modules/modules.nix {
@@ -26,7 +29,7 @@ let
home.homeDirectory = config.users.users.${name}.home;
};
})
- ];
+ ] ++ cfg.sharedModules;
};
in
@@ -55,6 +58,24 @@ in
'';
};
+ extraSpecialArgs = mkOption {
+ type = types.attrs;
+ default = { };
+ example = literalExample "{ modulesPath = ../modules; }";
+ description = ''
+ Extra specialArgs passed to Home Manager.
+ '';
+ };
+
+ sharedModules = mkOption {
+ type = with types; listOf (oneOf [ attrs (functionTo attrs) path ]);
+ default = [ ];
+ example = literalExample "[ { home.packages = [ nixpkgs-fmt ]; } ]";
+ description = ''
+ Extra modules added to all users.
+ '';
+ };
+
verbose = mkEnableOption "verbose output on activation";
users = mkOption {
diff --git a/nixos/default.nix b/nixos/default.nix
index 6645b9068..4b58d154c 100644
--- a/nixos/default.nix
+++ b/nixos/default.nix
@@ -12,7 +12,7 @@ let
specialArgs = {
lib = extendedLib;
nixosConfig = config;
- };
+ } // cfg.extraSpecialArgs;
modules = [
({ name, ... }: {
imports = import ../modules/modules.nix {
@@ -34,7 +34,7 @@ let
home.homeDirectory = config.users.users.${name}.home;
};
})
- ];
+ ] ++ cfg.sharedModules;
};
serviceEnvironment = optionalAttrs (cfg.backupFileExtension != null) {
@@ -65,6 +65,24 @@ in {
'';
};
+ extraSpecialArgs = mkOption {
+ type = types.attrs;
+ default = { };
+ example = literalExample "{ modulesPath = ../modules; }";
+ description = ''
+ Extra specialArgs passed to Home Manager.
+ '';
+ };
+
+ sharedModules = mkOption {
+ type = with types; listOf (oneOf [ attrs (functionTo attrs) path ]);
+ default = [ ];
+ example = literalExample "[ { home.packages = [ nixpkgs-fmt ]; } ]";
+ description = ''
+ Extra modules added to all users.
+ '';
+ };
+
verbose = mkEnableOption "verbose output on activation";
users = mkOption {