refactor: extract shared user-base home-manager module
This commit is contained in:
@@ -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
@@ -4,24 +4,24 @@ let
|
|||||||
|
|
||||||
realName = "Jelle Spreeuwenberg";
|
realName = "Jelle Spreeuwenberg";
|
||||||
|
|
||||||
accounts = {
|
kiri = {
|
||||||
kiri = {
|
name = "kiri";
|
||||||
homeDirectory = "/home/kiri";
|
homeDirectory = "/home/kiri";
|
||||||
gitEmail = "mail@jelles.net";
|
gitEmail = "mail@jelles.net";
|
||||||
vaultEmail = "mail@jelles.net";
|
vaultEmail = "mail@jelles.net";
|
||||||
extraHomeImports = with homeModules; [ syncthing ];
|
extraHomeImports = with homeModules; [ syncthing ];
|
||||||
};
|
};
|
||||||
|
|
||||||
ergon = {
|
ergon = {
|
||||||
homeDirectory = "/home/ergon";
|
name = "ergon";
|
||||||
gitEmail = "jelle.spreeuwenberg@yookr.org";
|
homeDirectory = "/home/ergon";
|
||||||
vaultEmail = "jelle.spreeuwenberg@yookr.org";
|
gitEmail = "jelle.spreeuwenberg@yookr.org";
|
||||||
extraHomeImports = with homeModules; [ nix ];
|
vaultEmail = "jelle.spreeuwenberg@yookr.org";
|
||||||
};
|
extraHomeImports = with homeModules; [ nix ];
|
||||||
};
|
};
|
||||||
|
|
||||||
mkUser =
|
mkUser =
|
||||||
{ accountName }:
|
account:
|
||||||
{
|
{
|
||||||
config,
|
config,
|
||||||
hostType ? "desktop",
|
hostType ? "desktop",
|
||||||
@@ -30,18 +30,18 @@ let
|
|||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
account = accounts.${accountName};
|
username = account.name;
|
||||||
isServer = hostType == "server";
|
isServer = hostType == "server";
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
sops.secrets = lib.optionalAttrs (!isServer) {
|
sops.secrets = lib.optionalAttrs (!isServer) {
|
||||||
"hashed-password-${accountName}".neededForUsers = true;
|
"hashed-password-${username}".neededForUsers = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
programs.zsh.enable = true;
|
programs.zsh.enable = true;
|
||||||
|
|
||||||
users.users.${accountName} = {
|
users.users.${username} = {
|
||||||
name = accountName;
|
name = username;
|
||||||
home = account.homeDirectory;
|
home = account.homeDirectory;
|
||||||
isNormalUser = true;
|
isNormalUser = true;
|
||||||
shell = pkgs.zsh;
|
shell = pkgs.zsh;
|
||||||
@@ -51,30 +51,17 @@ let
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
// lib.optionalAttrs (!isServer) {
|
// 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 = {
|
home = {
|
||||||
username = accountName;
|
inherit username;
|
||||||
homeDirectory = account.homeDirectory;
|
homeDirectory = account.homeDirectory;
|
||||||
stateVersion = "24.05";
|
stateVersion = "24.05";
|
||||||
};
|
};
|
||||||
|
|
||||||
imports =
|
imports = [ homeModules.userBase ] ++ account.extraHomeImports;
|
||||||
with homeModules;
|
|
||||||
[
|
|
||||||
terminal
|
|
||||||
shell
|
|
||||||
neovim
|
|
||||||
sshClient
|
|
||||||
sopsAdmin
|
|
||||||
git
|
|
||||||
devTools
|
|
||||||
podman
|
|
||||||
gemini
|
|
||||||
]
|
|
||||||
++ account.extraHomeImports;
|
|
||||||
|
|
||||||
programs.git.settings.user = {
|
programs.git.settings.user = {
|
||||||
name = realName;
|
name = realName;
|
||||||
@@ -86,7 +73,6 @@ let
|
|||||||
};
|
};
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
flake.modules.nixos.kiri = mkUser { accountName = "kiri"; };
|
flake.modules.nixos.kiri = mkUser kiri;
|
||||||
|
flake.modules.nixos.ergon = mkUser ergon;
|
||||||
flake.modules.nixos.ergon = mkUser { accountName = "ergon"; };
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user