modules/system: flatten
This commit is contained in:
parent
52c84814e8
commit
5c3f1dac68
14 changed files with 65 additions and 70 deletions
73
modules/system/user.nix
Normal file
73
modules/system/user.nix
Normal file
|
@ -0,0 +1,73 @@
|
|||
{
|
||||
config,
|
||||
options,
|
||||
lib,
|
||||
inputs,
|
||||
configurationName,
|
||||
...
|
||||
}@args:
|
||||
let
|
||||
hasHomeManager = options ? home-manager;
|
||||
cfg = config.settei.user;
|
||||
inherit (config.settei) username;
|
||||
in
|
||||
{
|
||||
_file = ./user.nix;
|
||||
|
||||
options.settei.user = with lib; {
|
||||
enable = mkEnableOption "User-specific configuration" // {
|
||||
default = true;
|
||||
};
|
||||
config = mkOption {
|
||||
type = types.deferredModule;
|
||||
default = { };
|
||||
};
|
||||
extraArgs = mkOption {
|
||||
type = types.attrs;
|
||||
default = { };
|
||||
};
|
||||
};
|
||||
|
||||
config =
|
||||
let
|
||||
hmConfig = lib.optionalAttrs hasHomeManager {
|
||||
home-manager.useGlobalPkgs = true;
|
||||
home-manager.useUserPackages = true;
|
||||
home-manager.extraSpecialArgs = {
|
||||
inherit (args) inputs inputs';
|
||||
machineName = configurationName;
|
||||
} // cfg.extraArgs;
|
||||
|
||||
home-manager.users.${username} = {
|
||||
_file = ./user.nix;
|
||||
|
||||
imports = [
|
||||
inputs.settei.homeModules.settei
|
||||
cfg.config
|
||||
];
|
||||
|
||||
home = {
|
||||
inherit username;
|
||||
homeDirectory = config.users.users.${username}.home;
|
||||
stateVersion = "22.05";
|
||||
};
|
||||
|
||||
programs.home-manager.enable = true;
|
||||
services.ssh-agent.enable = true;
|
||||
};
|
||||
};
|
||||
in
|
||||
lib.mkIf cfg.enable (
|
||||
lib.mkMerge [
|
||||
{
|
||||
assertions = [
|
||||
{
|
||||
assertion = hasHomeManager;
|
||||
message = "Home-manager module has to be imported before enabling settei.user";
|
||||
}
|
||||
];
|
||||
}
|
||||
hmConfig
|
||||
]
|
||||
);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue