Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nixos: add sharedModules and extraSpecialArgs options #1793

Merged
merged 3 commits into from
Feb 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 23 additions & 2 deletions nix-darwin/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Pacman99 marked this conversation as resolved.
Show resolved Hide resolved
modules = [
({ name, ... }: {
imports = import ../modules/modules.nix {
Expand All @@ -26,7 +29,7 @@ let
home.homeDirectory = config.users.users.${name}.home;
};
})
];
] ++ cfg.sharedModules;
};

in
Expand Down Expand Up @@ -55,6 +58,24 @@ in
'';
};

extraSpecialArgs = mkOption {
type = types.attrs;
default = { };
example = literalExample "{ modulesPath = ../modules; }";
description = ''
Extra <literal>specialArgs</literal> 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 {
Expand Down
22 changes: 20 additions & 2 deletions nixos/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ let
specialArgs = {
lib = extendedLib;
nixosConfig = config;
};
} // cfg.extraSpecialArgs;
modules = [
({ name, ... }: {
imports = import ../modules/modules.nix {
Expand All @@ -34,7 +34,7 @@ let
home.homeDirectory = config.users.users.${name}.home;
};
})
];
] ++ cfg.sharedModules;
};

serviceEnvironment = optionalAttrs (cfg.backupFileExtension != null) {
Expand Down Expand Up @@ -65,6 +65,24 @@ in {
'';
};

extraSpecialArgs = mkOption {
type = types.attrs;
default = { };
example = literalExample "{ modulesPath = ../modules; }";
description = ''
Extra <literal>specialArgs</literal> 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 {
Expand Down