Skip to content

Commit

Permalink
nixos/user-groups: add a toggle for user accounts
Browse files Browse the repository at this point in the history
Microscopic change that allows users to toggle user accounts, per user, conditionally.
  • Loading branch information
NotAShelf committed Nov 24, 2024
1 parent 518c682 commit 2d8b4eb
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions nixos/modules/config/users-groups.nix
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,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;
Expand Down Expand Up @@ -394,7 +404,7 @@ let
};
};

config = mkMerge
config = mkIf config.enable (mkMerge
[ { name = mkDefault name;
shell = mkIf config.useDefaultShell (mkDefault cfg.defaultUserShell);
}
Expand All @@ -417,7 +427,7 @@ let
(mkIf (config.isNormalUser && config.subUidRanges == [] && config.subGidRanges == []) {
autoSubUidGidRange = mkDefault true;
})
];
]);

};

Expand Down

0 comments on commit 2d8b4eb

Please sign in to comment.