2024-09-10 21:32:11 +00:00
|
|
|
{ lib, config, pkgs, ... }:
|
2018-01-13 01:05:45 +00:00
|
|
|
|
|
|
|
{
|
2018-01-13 13:02:25 +00:00
|
|
|
users.knownGroups = [ "foo" "created.group" "deleted.group" ];
|
2018-01-13 01:05:45 +00:00
|
|
|
users.groups.foo.gid = 42000;
|
|
|
|
users.groups.foo.description = "Foo group";
|
2018-01-14 12:31:15 +00:00
|
|
|
users.groups.foo.members = [ "admin" "foo" ];
|
2018-01-13 01:05:45 +00:00
|
|
|
|
2018-01-13 13:02:25 +00:00
|
|
|
users.groups."created.group".gid = 42001;
|
|
|
|
users.groups."unknown.group".gid = 42002;
|
|
|
|
|
|
|
|
users.knownUsers = [ "foo" "created.user" "deleted.user" ];
|
|
|
|
users.users.foo.uid = 42000;
|
|
|
|
users.users.foo.gid = 42000;
|
|
|
|
users.users.foo.description = "Foo user";
|
2018-01-15 23:55:42 +00:00
|
|
|
users.users.foo.isHidden = false;
|
2018-01-13 13:02:25 +00:00
|
|
|
users.users.foo.home = "/Users/foo";
|
2019-02-23 16:29:57 +00:00
|
|
|
users.users.foo.createHome = true;
|
2023-11-24 01:11:18 +00:00
|
|
|
users.users.foo.shell = pkgs.bashInteractive;
|
2018-01-13 13:02:25 +00:00
|
|
|
|
|
|
|
users.users."created.user".uid = 42001;
|
2024-10-24 11:58:35 +00:00
|
|
|
users.users."created.user".description = null;
|
2024-10-24 12:19:27 +00:00
|
|
|
users.users."created.user".home = null;
|
2024-10-24 14:16:19 +00:00
|
|
|
users.users."created.user".shell = null;
|
2024-10-24 11:58:35 +00:00
|
|
|
|
2018-01-13 13:02:25 +00:00
|
|
|
users.users."unknown.user".uid = 42002;
|
2018-01-13 01:05:45 +00:00
|
|
|
|
|
|
|
test = ''
|
2024-06-17 18:56:58 +00:00
|
|
|
set -v
|
|
|
|
|
|
|
|
# checking group creation in /activate
|
2024-10-21 23:08:41 +00:00
|
|
|
grep "dscl . -create ${lib.escapeShellArg "/Groups/foo"} PrimaryGroupID 42000" ${config.out}/activate
|
2024-10-21 23:24:06 +00:00
|
|
|
grep "dscl . -create ${lib.escapeShellArg "/Groups/foo"} RealName ${lib.escapeShellArg "Foo group"}" ${config.out}/activate
|
2024-10-21 23:08:41 +00:00
|
|
|
grep "dscl . -create ${lib.escapeShellArg "/Groups/created.group"} PrimaryGroupID 42001" ${config.out}/activate
|
2024-10-24 12:55:25 +00:00
|
|
|
(! grep "dscl . -delete ${lib.escapeShellArg "/Groups/created.group"}" ${config.out}/activate)
|
2018-01-13 13:02:25 +00:00
|
|
|
|
2024-06-17 18:56:58 +00:00
|
|
|
# checking group deletion in /activate
|
2024-10-21 23:08:41 +00:00
|
|
|
grep "dscl . -delete ${lib.escapeShellArg "/Groups/deleted.group"}" ${config.out}/activate
|
2024-10-24 12:55:25 +00:00
|
|
|
(! grep "dscl . -create ${lib.escapeShellArg "/Groups/deleted.group"}" ${config.out}/activate)
|
2018-01-13 13:02:25 +00:00
|
|
|
|
2018-01-14 12:31:15 +00:00
|
|
|
echo "checking group membership in /activate" >&2
|
2024-10-21 23:08:41 +00:00
|
|
|
grep "dscl . -create ${lib.escapeShellArg "/Groups/foo"} GroupMembership ${lib.escapeShellArgs [ "admin" "foo" ]}" ${config.out}/activate
|
|
|
|
grep "dscl . -create ${lib.escapeShellArg "/Groups/created.group"} GroupMembership" ${config.out}/activate
|
2018-01-14 12:31:15 +00:00
|
|
|
|
2024-06-17 18:56:58 +00:00
|
|
|
# checking unknown group in /activate
|
2024-10-24 11:58:35 +00:00
|
|
|
# checking groups not in knownGroups don't appear in /activate
|
2024-10-24 12:55:25 +00:00
|
|
|
(! grep "dscl . -create ${lib.escapeShellArg "/Groups/unknown.group"}" ${config.out}/activate)
|
|
|
|
(! grep "dscl . -delete ${lib.escapeShellArg "/Groups/unknown.group"}" ${config.out}/activate)
|
2018-01-13 13:02:25 +00:00
|
|
|
|
2024-06-17 18:56:58 +00:00
|
|
|
# checking user creation in /activate
|
2024-10-21 22:29:56 +00:00
|
|
|
grep "sysadminctl -addUser ${lib.escapeShellArgs [ "foo" "-UID" 42000 "-GID" 42000 "-fullName" "Foo user" "-home" "/Users/foo" "-shell" "/run/current-system/sw/bin/bash" ]}" ${config.out}/activate
|
2024-10-21 23:20:43 +00:00
|
|
|
grep "createhomedir -cu ${lib.escapeShellArg "foo"}" ${config.out}/activate
|
2024-10-24 14:16:19 +00:00
|
|
|
grep "sysadminctl -addUser ${lib.escapeShellArgs [ "created.user" "-UID" 42001 ]} .* ${lib.escapeShellArgs [ "-shell" "/usr/bin/false" ] }" ${config.out}/activate
|
2024-10-27 23:30:02 +00:00
|
|
|
grep "sysadminctl -addUser ${lib.escapeShellArg "created.user"} .* ${lib.escapeShellArgs [ "-home" "/var/empty" ]}" ${config.out}/activate
|
2024-10-27 13:37:55 +00:00
|
|
|
(! grep "dscl . -delete ${lib.escapeShellArg "/Users/created.user"}" ${config.out}/activate)
|
2024-10-24 14:07:34 +00:00
|
|
|
(! grep "dscl . -delete ${lib.escapeShellArg "/Groups/created.user"}" ${config.out}/activate)
|
2024-06-17 18:56:58 +00:00
|
|
|
|
|
|
|
# checking user properties always get updated in /activate
|
2024-10-24 11:58:35 +00:00
|
|
|
grep "dscl . -create ${lib.escapeShellArg "/Users/foo"} PrimaryGroupID 42000" ${config.out}/activate
|
|
|
|
grep "dscl . -create ${lib.escapeShellArg "/Users/foo"} RealName ${lib.escapeShellArg "Foo user"}" ${config.out}/activate
|
|
|
|
grep "createhomedir -cu ${lib.escapeShellArg "foo"}" ${config.out}/activate
|
2024-10-21 23:08:41 +00:00
|
|
|
grep "dscl . -create ${lib.escapeShellArg "/Users/foo"} UserShell ${lib.escapeShellArg "/run/current-system/sw/bin/bash"}" ${config.out}/activate
|
2024-10-24 11:58:35 +00:00
|
|
|
grep "dscl . -create ${lib.escapeShellArg "/Users/foo"} IsHidden 0" ${config.out}/activate
|
|
|
|
|
|
|
|
# checking user properties that are null don't get updated in /activate
|
|
|
|
(! grep "dscl . -create ${lib.escapeShellArg "/Users/created.user"} RealName" ${config.out}/activate)
|
2024-10-24 14:16:19 +00:00
|
|
|
(! grep "dscl . -create ${lib.escapeShellArg "/Users/created.user"} UserShell" ${config.out}/activate)
|
2024-06-17 18:56:58 +00:00
|
|
|
|
|
|
|
# checking user deletion in /activate
|
2024-10-27 13:37:55 +00:00
|
|
|
grep "dscl . -delete ${lib.escapeShellArg "/Users/deleted.user"}" ${config.out}/activate
|
2024-10-24 12:55:25 +00:00
|
|
|
(! grep "sysadminctl -addUser ${lib.escapeShellArg "deleted.user"}" ${config.out}/activate)
|
2018-01-13 13:02:25 +00:00
|
|
|
|
2024-10-24 11:58:35 +00:00
|
|
|
# checking that users not specified in knownUsers doesn't get changed in /activate
|
2024-10-24 12:55:25 +00:00
|
|
|
(! grep "sysadminctl -addUser ${lib.escapeShellArg "unknown.user"}" ${config.out}/activate)
|
2024-10-27 13:37:55 +00:00
|
|
|
(! grep "dscl . -delete ${lib.escapeShellArg "/Users/unknown.user"}" ${config.out}/activate)
|
2024-10-24 11:58:35 +00:00
|
|
|
(! grep "dscl . -create ${lib.escapeShellArg "/Users/unknown.user"}" ${config.out}/activate)
|
2018-01-13 13:02:25 +00:00
|
|
|
|
2024-06-17 18:56:58 +00:00
|
|
|
set +v
|
2018-01-13 01:05:45 +00:00
|
|
|
'';
|
|
|
|
}
|