refactor: extract shared user-base home-manager module

This commit is contained in:
2026-04-21 01:57:14 +02:00
parent 2572022349
commit 4bb3f44a37
2 changed files with 43 additions and 38 deletions
+19
View File
@@ -0,0 +1,19 @@
{ config, ... }:
let
homeModules = config.flake.modules.homeManager;
in
{
flake.modules.homeManager.userBase = {
imports = with homeModules; [
terminal
shell
neovim
sshClient
sopsAdmin
git
devTools
podman
gemini
];
};
}
+24 -38
View File
@@ -4,24 +4,24 @@ let
realName = "Jelle Spreeuwenberg";
accounts = {
kiri = {
homeDirectory = "/home/kiri";
gitEmail = "mail@jelles.net";
vaultEmail = "mail@jelles.net";
extraHomeImports = with homeModules; [ syncthing ];
};
kiri = {
name = "kiri";
homeDirectory = "/home/kiri";
gitEmail = "mail@jelles.net";
vaultEmail = "mail@jelles.net";
extraHomeImports = with homeModules; [ syncthing ];
};
ergon = {
homeDirectory = "/home/ergon";
gitEmail = "jelle.spreeuwenberg@yookr.org";
vaultEmail = "jelle.spreeuwenberg@yookr.org";
extraHomeImports = with homeModules; [ nix ];
};
ergon = {
name = "ergon";
homeDirectory = "/home/ergon";
gitEmail = "jelle.spreeuwenberg@yookr.org";
vaultEmail = "jelle.spreeuwenberg@yookr.org";
extraHomeImports = with homeModules; [ nix ];
};
mkUser =
{ accountName }:
account:
{
config,
hostType ? "desktop",
@@ -30,18 +30,18 @@ let
...
}:
let
account = accounts.${accountName};
username = account.name;
isServer = hostType == "server";
in
{
sops.secrets = lib.optionalAttrs (!isServer) {
"hashed-password-${accountName}".neededForUsers = true;
"hashed-password-${username}".neededForUsers = true;
};
programs.zsh.enable = true;
users.users.${accountName} = {
name = accountName;
users.users.${username} = {
name = username;
home = account.homeDirectory;
isNormalUser = true;
shell = pkgs.zsh;
@@ -51,30 +51,17 @@ let
];
}
// lib.optionalAttrs (!isServer) {
hashedPasswordFile = config.sops.secrets."hashed-password-${accountName}".path;
hashedPasswordFile = config.sops.secrets."hashed-password-${username}".path;
};
home-manager.users.${accountName} = {
home-manager.users.${username} = {
home = {
username = accountName;
inherit username;
homeDirectory = account.homeDirectory;
stateVersion = "24.05";
};
imports =
with homeModules;
[
terminal
shell
neovim
sshClient
sopsAdmin
git
devTools
podman
gemini
]
++ account.extraHomeImports;
imports = [ homeModules.userBase ] ++ account.extraHomeImports;
programs.git.settings.user = {
name = realName;
@@ -86,7 +73,6 @@ let
};
in
{
flake.modules.nixos.kiri = mkUser { accountName = "kiri"; };
flake.modules.nixos.ergon = mkUser { accountName = "ergon"; };
flake.modules.nixos.kiri = mkUser kiri;
flake.modules.nixos.ergon = mkUser ergon;
}