diff options
Diffstat (limited to 'modules/nixos/traits/host-user.nix')
| -rw-r--r-- | modules/nixos/traits/host-user.nix | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/modules/nixos/traits/host-user.nix b/modules/nixos/traits/host-user.nix new file mode 100644 index 0000000..2da91d6 --- /dev/null +++ b/modules/nixos/traits/host-user.nix @@ -0,0 +1,40 @@ +{ + config, + lib, + pkgs, + secretsDir, + ... +}: let + cfg = config.traits.users.hostUser; + inherit (config.networking) hostName; +in { + options.traits.users.hostUser = { + enable = lib.mkEnableOption "${hostName} user configuration"; + manageSecrets = + lib.mkEnableOption "automatic secrets management" + // { + default = config.traits.secrets.enable; + }; + }; + + config = lib.mkIf cfg.enable ( + lib.mkMerge [ + { + users.users.${hostName} = { + isNormalUser = true; + shell = pkgs.bash; + }; + } + + (lib.mkIf cfg.manageSecrets { + age.secrets = { + userPassword.file = secretsDir + "/userPassword.age"; + }; + + users.users.${hostName} = { + hashedPasswordFile = config.age.secrets.userPassword.path; + }; + }) + ] + ); +} |
