From 8817f0799818398e119dbd5819840719ecb5fd31 Mon Sep 17 00:00:00 2001 From: Gabriel Fontes Date: Sun, 4 Sep 2022 19:19:57 -0300 Subject: [PATCH] hosts/users: simpler conditional groups --- hosts/common/users/misterio.nix | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/hosts/common/users/misterio.nix b/hosts/common/users/misterio.nix index a16d7ac7..3797266c 100644 --- a/hosts/common/users/misterio.nix +++ b/hosts/common/users/misterio.nix @@ -1,6 +1,7 @@ { pkgs, config, lib, hostname, outputs, ... }: let homeConfig = outputs.homeConfigurations."misterio@${hostname}".config; + ifTheyExist = groups: builtins.filter (group: builtins.hasAttr group config.users.groups) groups; in { users.mutableUsers = false; @@ -11,14 +12,16 @@ in "wheel" "video" "audio" - ] - ++ (lib.optional config.networking.wireless.userControlled.enable config.networking.wireless.userControlled.group) - ++ (lib.optional config.programs.wireshark.enable "wireshark") - ++ (lib.optional config.hardware.i2c.enable "i2c") - ++ (lib.optional config.services.mysql.enable "mysql") - ++ (lib.optional config.virtualisation.docker.enable "docker") - ++ (lib.optional config.virtualisation.podman.enable "podman") - ++ (lib.optional config.virtualisation.libvirtd.enable "libvirtd"); + ] ++ ifTheyExist [ + "wireless" + "wireshark" + "i2c" + "mysql" + "docker" + "podman" + "git" + "libvirtd" + ]; openssh.authorizedKeys.keys = [ "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDci4wJghnRRSqQuX1z2xeaUR+p/muKzac0jw0mgpXE2T/3iVlMJJ3UXJ+tIbySP6ezt0GVmzejNOvUarPAm0tOcW6W0Ejys2Tj+HBRU19rcnUtf4vsKk8r5PW5MnwS8DqZonP5eEbhW2OrX5ZsVyDT+Bqrf39p3kOyWYLXT2wA7y928g8FcXOZjwjTaWGWtA+BxAvbJgXhU9cl/y45kF69rfmc3uOQmeXpKNyOlTk6ipSrOfJkcHgNFFeLnxhJ7rYxpoXnxbObGhaNqn7gc5mt+ek+fwFzZ8j6QSKFsPr0NzwTFG80IbyiyrnC/MeRNh7SQFPAESIEP8LK3PoNx2l1M+MjCQXsb4oIG2oYYMRa2yx8qZ3npUOzMYOkJFY1uI/UEE/j/PlQSzMHfpmWus4o2sijfr8OmVPGeoU/UnVPyINqHhyAd1d3Iji3y3LMVemHtp5wVcuswABC7IRVVKZYrMCXMiycY5n00ch6XTaXBwCY00y8B3Mzkd7Ofq98YHc= (none)"