mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-15 22:36:23 +01:00
Merge pull request #297250 from NickCao/sysuser
nixos/systemd-sysusers: make uid/gid allocation stable
This commit is contained in:
commit
0415aec200
1 changed files with 19 additions and 2 deletions
|
@ -12,7 +12,7 @@ let
|
|||
${lib.concatLines (lib.mapAttrsToList
|
||||
(username: opts:
|
||||
let
|
||||
uid = if opts.uid == null then "-" else toString opts.uid;
|
||||
uid = if opts.uid == null then "/var/lib/nixos/uid/${username}" else toString opts.uid;
|
||||
in
|
||||
''u ${username} ${uid}:${opts.group} "${opts.description}" ${opts.home} ${utils.toShellPath opts.shell}''
|
||||
)
|
||||
|
@ -21,7 +21,7 @@ let
|
|||
|
||||
# Groups
|
||||
${lib.concatLines (lib.mapAttrsToList
|
||||
(groupname: opts: ''g ${groupname} ${if opts.gid == null then "-" else toString opts.gid}'') userCfg.groups)
|
||||
(groupname: opts: ''g ${groupname} ${if opts.gid == null then "/var/lib/nixos/gid/${groupname}" else toString opts.gid}'') userCfg.groups)
|
||||
}
|
||||
|
||||
# Group membership
|
||||
|
@ -106,6 +106,23 @@ in
|
|||
};
|
||||
})
|
||||
(lib.filterAttrs (_username: opts: opts.home != "/var/empty") userCfg.users);
|
||||
|
||||
# Create uid/gid marker files for those without an explicit id
|
||||
tmpfiles.settings.nixos-uid = lib.mapAttrs'
|
||||
(username: opts: lib.nameValuePair "/var/lib/nixos/uid/${username}" {
|
||||
f = {
|
||||
user = username;
|
||||
};
|
||||
})
|
||||
(lib.filterAttrs (_username: opts: opts.uid == null) userCfg.users);
|
||||
|
||||
tmpfiles.settings.nixos-gid = lib.mapAttrs'
|
||||
(groupname: opts: lib.nameValuePair "/var/lib/nixos/gid/${groupname}" {
|
||||
f = {
|
||||
group = groupname;
|
||||
};
|
||||
})
|
||||
(lib.filterAttrs (_groupname: opts: opts.gid == null) userCfg.groups);
|
||||
})
|
||||
|
||||
(lib.mkIf config.users.mutableUsers {
|
||||
|
|
Loading…
Reference in a new issue