From 911d7d6905fabc1e1527ddbc6dba4dbf56874f0b Mon Sep 17 00:00:00 2001 From: Sam Date: Fri, 5 Jul 2024 16:32:49 +0100 Subject: [PATCH] ifTheuExist and extra groups to user sam --- hosts/common/users/admin/default.nix | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/hosts/common/users/admin/default.nix b/hosts/common/users/admin/default.nix index 5b9827c..670f5b2 100644 --- a/hosts/common/users/admin/default.nix +++ b/hosts/common/users/admin/default.nix @@ -1,5 +1,6 @@ { pkgs, inputs, config, lib, ... }: let + ifTheyExist = groups: builtins.filter (group: builtins.hasAttr group config.users.groups) groups; username = "admin"; pubKeys = lib.filesystem.listFilesRecursive (../keys); hostname = config.networking.hostName; @@ -7,7 +8,7 @@ let secretsDirectory = builtins.toString inputs.nix-secrets; secretsFile = "${secretsDirectory}/secrets.yaml"; -in +in { users.users.${username} = { isNormalUser = true; @@ -15,7 +16,13 @@ in hashedPasswordFile = sopsHashedPasswordFile; openssh.authorizedKeys.keys = lib.lists.forEach pubKeys (key: builtins.readFile key); - extraGroups = ["wheel"]; + extraGroups = [ + "wheel" + ] ++ ifTheyExist [ + "docker" + "lxc" + "git" + ]; packages = with pkgs; [ ]; @@ -30,7 +37,7 @@ in 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";