diff --git a/nix/nixosModules.nix b/nix/nixosModules.nix index fbff28e18b62c..e551b261d5b5e 100644 --- a/nix/nixosModules.nix +++ b/nix/nixosModules.nix @@ -115,9 +115,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) ──