nixos/hosts/common/users/admin/default.nix

62 lines
1.4 KiB
Nix
Raw Normal View History

2025-01-20 09:58:16 +00:00
{
pkgs,
inputs,
config,
lib,
...
}: let
2024-05-27 15:04:34 +01:00
username = "admin";
2025-01-19 19:18:31 +00:00
pubKeys = lib.filesystem.listFilesRecursive ../keys;
2024-05-27 15:04:34 +01:00
hostname = config.networking.hostName;
2025-01-19 19:18:31 +00:00
sopsHashedPasswordFile = config.sops.secrets."passwords/${username}".path;
2024-05-27 15:04:34 +01:00
secretsDirectory = builtins.toString inputs.nix-secrets;
secretsFile = "${secretsDirectory}/secrets.yaml";
2025-01-20 09:58:16 +00:00
in {
2024-05-27 15:04:34 +01:00
users.users.${username} = {
2024-05-14 14:51:09 +01:00
isNormalUser = true;
2025-01-19 19:18:31 +00:00
shell = pkgs.zsh;
2024-05-27 15:04:34 +01:00
hashedPasswordFile = sopsHashedPasswordFile;
2024-05-14 14:51:09 +01:00
openssh.authorizedKeys.keys = lib.lists.forEach pubKeys (key: builtins.readFile key);
extraGroups = [
"wheel"
2024-05-27 15:04:34 +01:00
];
};
2025-01-19 19:40:01 +00:00
environment.persistence."/persist" = {
directories = [
"/home/${username}"
];
};
2024-05-27 15:04:34 +01:00
sops.secrets = {
"passwords/${username}" = {
sopsFile = "${secretsFile}";
neededForUsers = true;
};
2025-01-20 09:58:16 +00:00
"ssh_keys/${username}/id_ed25519" = {
path = "/home/${username}/.ssh/id_ed25519";
mode = "0600";
owner = "${username}";
};
"ssh_keys/${username}/id_ed25519.pub" = {
path = "/home/${username}/.ssh/id_ed25519.pub";
mode = "0644";
owner = "${username}";
};
"github-access-token" = {
mode = "0655";
};
2024-05-14 14:51:09 +01:00
};
programs.zsh.enable = true;
2024-05-27 15:04:34 +01:00
programs.fuse.userAllowOther = true;
2024-05-14 14:51:09 +01:00
2024-05-27 15:04:34 +01:00
home-manager = {
2025-01-20 09:58:16 +00:00
extraSpecialArgs = {inherit inputs;};
2024-05-27 15:04:34 +01:00
users = {
${username} = import ../../../../home/${hostname}.nix;
};
};
2024-05-14 14:51:09 +01:00
}