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

58 lines
1.5 KiB
Nix
Raw Normal View History

2024-05-14 14:51:09 +01:00
{ pkgs, inputs, config, lib, ... }:
let
2024-06-29 14:39:16 +01:00
ifTheyExist = groups: builtins.filter (group: builtins.hasAttr group config.users.groups) groups;
2024-05-27 15:04:34 +01:00
username = "admin";
2024-05-14 14:51:09 +01:00
pubKeys = lib.filesystem.listFilesRecursive (../keys);
2024-05-27 15:04:34 +01:00
hostname = config.networking.hostName;
sopsHashedPasswordFile = lib.optionalString (lib.hasAttr "sops-nix" inputs) config.sops.secrets."passwords/${username}".path;
secretsDirectory = builtins.toString inputs.nix-secrets;
secretsFile = "${secretsDirectory}/secrets.yaml";
2024-06-29 14:39:16 +01:00
in
2024-05-14 14:51:09 +01:00
{
2024-05-27 15:04:34 +01:00
users.users.${username} = {
2024-05-14 14:51:09 +01:00
isNormalUser = true;
shell = pkgs.zsh; # default shell
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);
2024-06-29 14:39:16 +01:00
extraGroups = [
"wheel"
] ++ ifTheyExist [
"docker"
"lxc"
"git"
];
2024-05-14 14:51:09 +01:00
2024-05-27 15:04:34 +01:00
packages = with pkgs; [
];
};
sops.secrets = {
"passwords/${username}" = {
sopsFile = "${secretsFile}";
neededForUsers = true;
};
"ssh_keys/${username}/id_ed25519" = {
path = "/home/${username}/.ssh/id_ed25519";
mode = "0600";
owner = "${username}";
2024-06-29 14:39:16 +01:00
};
2024-05-27 15:04:34 +01:00
"ssh_keys/${username}/id_ed25519.pub" = {
path = "/home/${username}/.ssh/id_ed25519.pub";
mode = "0644";
owner = "${username}";
};
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 = {
extraSpecialArgs = { inherit inputs; };
users = {
${username} = import ../../../../home/${hostname}.nix;
};
};
2024-05-14 14:51:09 +01:00
}