mirror of
https://github.com/nix-community/impermanence
synced 2024-11-10 05:44:17 +00:00
Merge pull request #188 from kuruczgy/add-var-lib-nixos-assertion
nixos: Add assertion for persisting UIDs/GIDs
This commit is contained in:
commit
9de98e038a
1 changed files with 15 additions and 0 deletions
15
nixos.nix
15
nixos.nix
|
@ -682,6 +682,9 @@ in
|
|||
homeDirOffenders =
|
||||
filterAttrs
|
||||
(n: v: (v.home != config.users.users.${n}.home));
|
||||
usersWithoutUid = attrNames (filterAttrs (n: u: u.uid == null) config.users.users);
|
||||
groupsWithoutGid = attrNames (filterAttrs (n: g: g.gid == null) config.users.groups);
|
||||
varLibNixosPersisted = elem "/var/lib/nixos" (catAttrs "dirPath" directories);
|
||||
in
|
||||
[
|
||||
{
|
||||
|
@ -753,6 +756,18 @@ in
|
|||
${concatStringsSep "\n " offenders}
|
||||
'';
|
||||
}
|
||||
{
|
||||
assertion = varLibNixosPersisted || (usersWithoutUid == [ ] && groupsWithoutGid == [ ]);
|
||||
message = ''
|
||||
environment.persistence:
|
||||
Either "/var/lib/nixos" has to be persisted, or all users and
|
||||
groups must have a uid/gid specified. The following users are
|
||||
missing a uid:
|
||||
${concatStringsSep "\n " usersWithoutUid}
|
||||
The following groups are missing a gid:
|
||||
${concatStringsSep "\n " groupsWithoutGid}
|
||||
'';
|
||||
}
|
||||
];
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue