diff options
| author | seth <[email protected]> | 2024-02-07 18:03:24 -0500 |
|---|---|---|
| committer | seth <[email protected]> | 2024-02-07 18:27:45 -0500 |
| commit | cffffeb678e9a1078eeba0f19c9607cda9f31bed (patch) | |
| tree | 8b8f68aa357becad06845f15b7e528474041371c /modules/nixos/traits/users.nix | |
| parent | 48712d44fde91d2685089cca7f9d88295fd59817 (diff) | |
modules/nixos+darwin: move to traits + archetypes model
Diffstat (limited to 'modules/nixos/traits/users.nix')
| -rw-r--r-- | modules/nixos/traits/users.nix | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/modules/nixos/traits/users.nix b/modules/nixos/traits/users.nix new file mode 100644 index 0000000..3302366 --- /dev/null +++ b/modules/nixos/traits/users.nix @@ -0,0 +1,44 @@ +{ + config, + lib, + pkgs, + secretsDir, + ... +}: let + cfg = config.traits.users; + inherit (config.networking) hostName; +in { + imports = [ + ../../../users/seth/nixos.nix + ]; + + options.traits.users = { + hostUser = { + enable = lib.mkEnableOption "${hostName} user configuration"; + manageSecrets = + lib.mkEnableOption "automatically manage secrets" + // { + default = config.traits.secrets.enable; + }; + }; + }; + + config = lib.mkMerge [ + (lib.mkIf cfg.hostUser.enable { + users.users.${hostName} = { + isNormalUser = true; + shell = pkgs.bash; + }; + }) + + (lib.mkIf (cfg.hostUser.enable && cfg.hostUser.manageSecrets) { + age.secrets = { + userPassword.file = secretsDir + "/userPassword.age"; + }; + + users.users.${hostName} = { + hashedPasswordFile = config.age.secrets.userPassword.path; + }; + }) + ]; +} |
