Merge pull request #203 from nix-community/fs-var-lib-nixos-warning

nixos: Consider regular filesystem mounts in /var/lib/nixos warning
This commit is contained in:
Kim Lindberger 2024-09-07 08:32:02 +02:00 committed by GitHub
commit 63f4d0443e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -772,17 +772,19 @@ in
let
usersWithoutUid = attrNames (filterAttrs (n: u: u.uid == null) config.users.users);
groupsWithoutGid = attrNames (filterAttrs (n: g: g.gid == null) config.users.groups);
varLibNixosPersisted =
varLibNixosPersistent =
let
varDirs = parentsOf "/var/lib/nixos" ++ [ "/var/lib/nixos" ];
persistedDirs = catAttrs "dirPath" directories;
mountedDirs = catAttrs "mountPoint" (attrValues config.fileSystems);
persistedVarDirs = intersectLists varDirs persistedDirs;
mountedVarDirs = intersectLists varDirs mountedDirs;
in
persistedVarDirs != [ ];
persistedVarDirs != [ ] || mountedVarDirs != [ ];
in
mkIf (any id allPersistentStoragePaths.enableWarnings)
(mkMerge [
(mkIf (!varLibNixosPersisted && (usersWithoutUid != [ ] || groupsWithoutGid != [ ])) [
(mkIf (!varLibNixosPersistent && (usersWithoutUid != [ ] || groupsWithoutGid != [ ])) [
''
environment.persistence:
Neither /var/lib/nixos nor any of its parents are