Manage users with the option system

This commit is contained in:
SebastianStork 2025-06-13 16:21:42 +02:00
parent 9386dc29d7
commit d7070b6fb5
15 changed files with 79 additions and 71 deletions

View file

@ -0,0 +1,61 @@
{
config,
self,
inputs,
pkgs,
pkgs-unstable,
lib,
...
}:
let
cfg = config.custom.users.seb;
in
{
imports = [ inputs.home-manager.nixosModules.home-manager ];
options.custom.users.seb = {
enable = lib.mkEnableOption "";
zsh.enable = lib.mkEnableOption "";
homeManager = {
enable = lib.mkEnableOption "";
configPath = lib.mkOption {
type = lib.types.listOf lib.types.path;
default = [
"${self}/users/shared-home.nix"
"${self}/users/seb/home.nix"
"${self}/users/seb/@${config.networking.hostName}/home.nix"
];
};
};
};
config = lib.mkIf cfg.enable (
lib.mkMerge [
{
sops.secrets."seb-password".neededForUsers = true;
users.users.seb = {
isNormalUser = true;
description = "Sebastian Stork";
hashedPasswordFile = config.sops.secrets."seb-password".path;
extraGroups = [ "wheel" ];
shell = lib.mkIf cfg.zsh.enable pkgs.zsh;
};
programs.zsh.enable = lib.mkIf cfg.zsh.enable true;
}
(lib.mkIf cfg.homeManager.enable {
home-manager = {
useGlobalPkgs = true;
useUserPackages = true;
extraSpecialArgs = {
inherit inputs self pkgs-unstable;
};
users.seb.imports = cfg.homeManager.configPath;
};
})
]
);
}