From 1dd23b5d74525ec5a093d43f73535a94aa5a9c86 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Sun, 24 Nov 2024 11:28:32 +0300 Subject: [PATCH] nixos/user-groups: add a toggle for user account creation Microscopic change that allows users to toggle user accounts, per user, conditionally. --- nixos/doc/manual/release-notes/rl-2505.section.md | 3 +++ nixos/modules/config/users-groups.nix | 12 +++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/nixos/doc/manual/release-notes/rl-2505.section.md b/nixos/doc/manual/release-notes/rl-2505.section.md index 3cc413fcac5e..7fda749b13ab 100644 --- a/nixos/doc/manual/release-notes/rl-2505.section.md +++ b/nixos/doc/manual/release-notes/rl-2505.section.md @@ -462,8 +462,11 @@ - `gerbera` now has wavpack support. +- A toggle has been added under `users.users..enable` to allow toggling individual users conditionally. If set to false, the user account will not be created. + - `ddclient` was updated from 3.11.2 to 4.0.0 [Release notes](https://github.com/ddclient/ddclient/releases/tag/v4.0.0) + ```{=include=} sections diff --git a/nixos/modules/config/users-groups.nix b/nixos/modules/config/users-groups.nix index eb3c6c1bef7c..86d0ad9b41b7 100644 --- a/nixos/modules/config/users-groups.nix +++ b/nixos/modules/config/users-groups.nix @@ -124,6 +124,16 @@ let options = { + enable = mkOption { + type = types.bool; + default = true; + example = false; + description = '' + If set to false, the user account will not be created. This is useful for when you wish to conditionally + disable user accounts. + ''; + }; + name = mkOption { type = types.passwdEntry types.str; apply = x: assert (stringLength x < 32 || abort "Username '${x}' is longer than 31 characters which is not allowed!"); x; @@ -557,7 +567,7 @@ let autoSubUidGidRange subUidRanges subGidRanges initialPassword initialHashedPassword expires; shell = utils.toShellPath u.shell; - }) cfg.users; + }) (filterAttrs (_: u: u.enable) cfg.users); groups = attrValues cfg.groups; });