aboutsummaryrefslogtreecommitdiff
path: root/infra/modules
diff options
context:
space:
mode:
authorvkcku <[email protected]>2026-06-01 12:34:38 +0530
committervkcku <[email protected]>2026-06-01 12:34:38 +0530
commita07fdcd1ed6db6f77181926126dc20cde6ab13b9 (patch)
treed4fda382e025104ef9ba792dca201989b29dd529 /infra/modules
parentinfra: add secrets management to base module (diff)
infra: add user configuration to base module
monorepo-revid: e84dab4473e390ec7f8d6974b656bf01a00eb557
Diffstat (limited to 'infra/modules')
-rw-r--r--infra/modules/base/user.nix36
1 files changed, 36 insertions, 0 deletions
diff --git a/infra/modules/base/user.nix b/infra/modules/base/user.nix
new file mode 100644
index 0000000..be1aeea
--- /dev/null
+++ b/infra/modules/base/user.nix
@@ -0,0 +1,36 @@
+{
+ flake.modules.nixos.base =
+ {
+ config,
+ lib,
+ pkgs,
+ ...
+ }:
+ {
+ options.infra.user = lib.mkOption {
+ type = lib.types.str;
+ default = "vkcku";
+ description = "The name of the main user.";
+ };
+
+ config =
+ let
+ username = config.infra.user;
+ passwordKey = "hosts/${config.networking.hostName}/users/${username}";
+ in
+ {
+ sops.secrets."${passwordKey}".neededForUsers = true;
+
+ users.mutableUsers = false;
+
+ users.users."${username}" = {
+ isNormalUser = true;
+ createHome = true;
+ home = "/home/${username}";
+ extraGroups = [ "wheel" ];
+ shell = pkgs.nushell;
+ hashedPasswordFile = config.sops.secrets."${passwordKey}".path;
+ };
+ };
+ };
+}