From 1a99f1ecc2cc72f64c2366ad39c6c66c84262499 Mon Sep 17 00:00:00 2001 From: Aly Raffauf Date: Tue, 2 Jul 2024 16:23:27 -0400 Subject: [PATCH] nixos/users: add defaultGroups option for users --- nixosModules/options.nix | 15 +++++++++++++++ nixosModules/users/aly/default.nix | 11 ++++++----- nixosModules/users/dustin/default.nix | 9 ++++----- nixosModules/users/morgan/default.nix | 9 ++++----- 4 files changed, 29 insertions(+), 15 deletions(-) diff --git a/nixosModules/options.nix b/nixosModules/options.nix index f2a2ac0d..9f4f7920 100644 --- a/nixosModules/options.nix +++ b/nixosModules/options.nix @@ -248,6 +248,21 @@ }; users = { + defaultGroups = lib.mkOption { + description = "Default groups for desktop users."; + default = [ + "dialout" + "docker" + "libvirtd" + "lp" + "networkmanager" + "scanner" + "transmission" + "video" + "wheel" + ]; + }; + aly = { enable = lib.mkEnableOption "Aly's user."; diff --git a/nixosModules/users/aly/default.nix b/nixosModules/users/aly/default.nix index 70471a54..90ed823d 100644 --- a/nixosModules/users/aly/default.nix +++ b/nixosModules/users/aly/default.nix @@ -17,17 +17,16 @@ }; home-manager.users.aly = - if config.ar.users.aly.manageHome - then import ../../../homes/aly - else {}; + lib.attrsets.optionalAttrs + config.ar.users.aly.manageHome + (import ../../../homes/aly); users.users.aly = { description = "Aly Raffauf"; - extraGroups = ["networkmanager" "wheel" "docker" "libvirtd" "video"]; + extraGroups = config.ar.users.defaultGroups; hashedPassword = config.ar.users.aly.password; isNormalUser = true; linger = true; - uid = 1000; openssh.authorizedKeys = { keys = [ @@ -42,6 +41,8 @@ ../../../secrets/publicKeys/aly_rustboro.pub ]; }; + + uid = 1000; }; }; } diff --git a/nixosModules/users/dustin/default.nix b/nixosModules/users/dustin/default.nix index 48b2337f..9b3215cb 100644 --- a/nixosModules/users/dustin/default.nix +++ b/nixosModules/users/dustin/default.nix @@ -6,15 +6,14 @@ }: { config = lib.mkIf config.ar.users.dustin.enable { home-manager.users.dustin = - if config.ar.users.dustin.manageHome - then import ../../../homes/dustin - else {}; + lib.attrsets.optionalAttrs + config.ar.users.dustin.manageHome + (import ../../../homes/dustin); users.users.dustin = { description = "Dustin Raffauf"; - extraGroups = ["networkmanager" "wheel" "docker" "libvirtd" "video"]; + extraGroups = config.ar.users.defaultGroups; hashedPassword = config.ar.users.dustin.password; - isNormalUser = true; uid = 1001; }; diff --git a/nixosModules/users/morgan/default.nix b/nixosModules/users/morgan/default.nix index 09387420..92b500cf 100644 --- a/nixosModules/users/morgan/default.nix +++ b/nixosModules/users/morgan/default.nix @@ -6,15 +6,14 @@ }: { config = lib.mkIf config.ar.users.morgan.enable { home-manager.users.morgan = - if config.ar.users.morgan.manageHome - then import ../../../homes/morgan - else {}; + lib.attrsets.optionalAttrs + config.ar.users.morgan.manageHome + (import ../../../homes/morgan); users.users.morgan = { description = "Morgan Tamayo"; - extraGroups = ["networkmanager" "wheel" "docker" "libvirtd" "video"]; + extraGroups = config.ar.users.defaultGroups; hashedPassword = config.ar.users.morgan.password; - isNormalUser = true; uid = 1002; };