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;
|
|
|
|
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
|
|
|
|
grep "dscl . -create ${lib.escapeShellArg "/Groups/foo"} RealName 'Foo group'" ${config.out}/activate
|
|
|
|
grep "dscl . -create ${lib.escapeShellArg "/Groups/created.group"} PrimaryGroupID 42001" ${config.out}/activate
|
|
|
|
grep -qv "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
|
|
|
|
grep -qv "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-21 23:08:41 +00:00
|
|
|
grep -qv "dscl . -create ${lib.escapeShellArg "/Groups/unknown.group"}" ${config.out}/activate
|
|
|
|
grep -qv "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-21 22:29:56 +00:00
|
|
|
grep "sysadminctl -addUser ${lib.escapeShellArgs [ "created.user" "-UID" 42001 ]} .* ${lib.escapeShellArgs [ "-shell" "/sbin/nologin" ]}" ${config.out}/activate
|
2024-10-21 20:05:10 +00:00
|
|
|
grep -qv "sysadminctl -deleteUser ${lib.escapeShellArg "created.user"}" ${config.out}/activate
|
|
|
|
grep -qv "sysadminctl -deleteUser ${lib.escapeShellArg "created.user"}" ${config.out}/activate
|
2024-06-17 18:56:58 +00:00
|
|
|
|
|
|
|
# checking user properties always get updated in /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-06-17 18:56:58 +00:00
|
|
|
|
|
|
|
# checking user deletion in /activate
|
2024-10-21 20:05:10 +00:00
|
|
|
grep "sysadminctl -deleteUser ${lib.escapeShellArg "deleted.user"}" ${config.out}/activate
|
2024-10-21 22:29:56 +00:00
|
|
|
grep -qv "sysadminctl -addUser ${lib.escapeShellArg "deleted.user"}" ${config.out}/activate
|
2018-01-13 13:02:25 +00:00
|
|
|
|
2024-06-17 18:56:58 +00:00
|
|
|
# checking unknown user in /activate
|
2024-10-21 22:29:56 +00:00
|
|
|
grep -qv "sysadminctl -addUser ${lib.escapeShellArg "unknown.user"}" ${config.out}/activate
|
2024-10-21 20:05:10 +00:00
|
|
|
grep -qv "sysadminctl -deleteUser ${lib.escapeShellArg "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
|
|
|
'';
|
|
|
|
}
|