diff --git a/nix/nixosModules.nix b/nix/nixosModules.nix index 475e5b5ba5a..f5c067a6398 100644 --- a/nix/nixosModules.nix +++ b/nix/nixosModules.nix @@ -117,9 +117,13 @@ chown "$HERMES_UID:$HERMES_GID" "$TARGET_HOME" chmod 0750 "$TARGET_HOME" - # Ensure HERMES_HOME is owned by the target user + # Ensure HERMES_HOME is owned by the target user. + # Use find instead of chown -R: chown strips the setgid bit (kernel + # behavior), destroying the 2770 permissions the NixOS activation + # script sets for group access by hostUsers. Only touch files with + # wrong ownership so correctly-owned dirs keep their permission bits. if [ -n "''${HERMES_HOME:-}" ] && [ -d "$HERMES_HOME" ]; then - chown -R "$HERMES_UID:$HERMES_GID" "$HERMES_HOME" + find "$HERMES_HOME" \! -user "$HERMES_UID" -exec chown "$HERMES_UID:$HERMES_GID" {} + fi # ── Provision apt packages (first boot only, cached in writable layer) ──