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

56 lines
1.4 KiB
Nix
Raw Normal View History

2024-05-14 14:51:09 +01:00
{ pkgs, inputs, config, lib, ... }:
let
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-05-14 14:51:09 +01:00
in
{
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);
extraGroups =
2024-05-27 15:04:34 +01:00
[
"wheel"
2024-05-14 14:51:09 +01:00
];
2024-05-27 15:04:34 +01:00
packages = with pkgs; [
flatpak
gnome.gnome-software
];
};
sops.secrets = {
"passwords/${username}" = {
sopsFile = "${secretsFile}";
neededForUsers = true;
};
"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}";
};
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
}