···555555556556- `gerbera` now has wavpack support.
557557558558+- A toggle has been added under `users.users.<name>.enable` to allow toggling individual users conditionally. If set to false, the user account will not be created.
559559+558560- `ddclient` was updated from 3.11.2 to 4.0.0 [Release notes](https://github.com/ddclient/ddclient/releases/tag/v4.0.0)
559561560562<!-- To avoid merge conflicts, consider adding your item at an arbitrary place in the list instead. -->
+11-1
nixos/modules/config/users-groups.nix
···124124125125 options = {
126126127127+ enable = mkOption {
128128+ type = types.bool;
129129+ default = true;
130130+ example = false;
131131+ description = ''
132132+ If set to false, the user account will not be created. This is useful for when you wish to conditionally
133133+ disable user accounts.
134134+ '';
135135+ };
136136+127137 name = mkOption {
128138 type = types.passwdEntry types.str;
129139 apply = x: assert (stringLength x < 32 || abort "Username '${x}' is longer than 31 characters which is not allowed!"); x;
···557567 autoSubUidGidRange subUidRanges subGidRanges
558568 initialPassword initialHashedPassword expires;
559569 shell = utils.toShellPath u.shell;
560560- }) cfg.users;
570570+ }) (filterAttrs (_: u: u.enable) cfg.users);
561571 groups = attrValues cfg.groups;
562572 });
563573
···11+let
22+ normal-enabled = "username-normal-enabled";
33+ normal-disabled = "username-normal-disabled";
44+ system-enabled = "username-system-enabled";
55+ system-disabled = "username-system-disabled";
66+ passwd = "enableOptionPasswd";
77+in
88+{
99+ name = "user-enable-option";
1010+1111+ nodes.machine = {
1212+ users = {
1313+ groups.test-group = { };
1414+ users = {
1515+ # User is enabled (default behaviour).
1616+ ${normal-enabled} = {
1717+ enable = true;
1818+ isNormalUser = true;
1919+ initialPassword = passwd;
2020+ };
2121+2222+ # User is disabled.
2323+ ${normal-disabled} = {
2424+ enable = false;
2525+ isNormalUser = true;
2626+ initialPassword = passwd;
2727+ };
2828+2929+ # User is a system user, and is enabled.
3030+ ${system-enabled} = {
3131+ enable = true;
3232+ isSystemUser = true;
3333+ initialPassword = passwd;
3434+ group = "test-group";
3535+ };
3636+3737+ # User is a system user, and is disabled.
3838+ ${system-disabled} = {
3939+ enable = false;
4040+ isSystemUser = true;
4141+ initialPassword = passwd;
4242+ group = "test-group";
4343+ };
4444+ };
4545+ };
4646+ };
4747+4848+ testScript = ''
4949+ def switch_to_tty(tty_number):
5050+ machine.fail(f"pgrep -f 'agetty.*tty{tty_number}'")
5151+ machine.send_key(f"alt-f{tty_number}")
5252+ machine.wait_until_succeeds(f"[ $(fgconsole) = {tty_number} ]")
5353+ machine.wait_for_unit(f"getty@tty{tty_number}.service")
5454+ machine.wait_until_succeeds(f"pgrep -f 'agetty.*tty{tty_number}'")
5555+5656+ machine.wait_for_unit("multi-user.target")
5757+ machine.wait_for_unit("getty@tty1.service")
5858+5959+ with subtest("${normal-enabled} exists"):
6060+ check_fn = f"id ${normal-enabled}"
6161+ machine.succeed(check_fn)
6262+ machine.wait_until_tty_matches("1", "login: ")
6363+ machine.send_chars("${normal-enabled}\n")
6464+ machine.wait_until_tty_matches("1", "Password: ")
6565+ machine.send_chars("${passwd}\n")
6666+6767+ with subtest("${normal-disabled} does not exist"):
6868+ switch_to_tty(2)
6969+ check_fn = f"id ${normal-disabled}"
7070+ machine.fail(check_fn)
7171+7272+ with subtest("${system-enabled} exists"):
7373+ switch_to_tty(3)
7474+ check_fn = f"id ${system-enabled}"
7575+ machine.succeed(check_fn)
7676+7777+ with subtest("${system-disabled} does not exist"):
7878+ switch_to_tty(4)
7979+ check_fn = f"id ${system-disabled}"
8080+ machine.fail(check_fn)
8181+ '';
8282+}
+9
nixos/tests/userborn.nix
···6666 isNormalUser = true;
6767 hashedPassword = newNormaloHashedPassword;
6868 };
6969+ normalo-disabled = {
7070+ enable = false;
7171+ isNormalUser = true;
7272+ };
6973 };
7074 groups = {
7175 new-group = { };
···9599 print(machine.succeed("getent passwd sysuser"))
96100 assert 1000 > int(machine.succeed("id --user sysuser")), "sysuser user doesn't have a system UID"
97101 assert "${sysuserInitialHashedPassword}" in machine.succeed("getent shadow sysuser"), "system user password is not correct"
102102+103103+ with subtest("normalo-disabled is NOT created"):
104104+ machine.fail("id normalo-disabled")
105105+ # Check if user's home has been created
106106+ machine.fail("[ -d '/home/normalo-disabled' ]")
9810799108 with subtest("sysusers group is created"):
100109 print(machine.succeed("getent group sysusers"))