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