Skip to content

fix(ci): clean /homeless-shelter between Renovate's Nix builds - #1085

Merged
jbw976 merged 1 commit into
crossplane:mainfrom
jbw976:nix-go-home
Jul 28, 2026
Merged

fix(ci): clean /homeless-shelter between Renovate's Nix builds#1085
jbw976 merged 1 commit into
crossplane:mainfrom
jbw976:nix-go-home

Conversation

@jbw976

@jbw976 jbw976 commented Jul 28, 2026

Copy link
Copy Markdown
Member

Description of your changes

This PR sets out to solve the same problem as crossplane/crossplane#7652, where our Renovate job fails intermittently with error: home directory '/homeless-shelter' exists, as in this example.

In crossplane/crossplane the fix has to prevent creation of the dir rather than cleaning it up afterwards, but we need a different fix here because the builds that create the directory (e.g., pkgs.gomod2nix) come from our dependencies rather than our own Nix code, so we have nowhere to set a writeable HOME here.

This PR adds a post-build-hook that deletes /homeless-shelter after each build, and sets max-jobs = 1 so no new build starts before we can clean it up.

Only main needs this since all Renovate runs use the entrypoint from main, regardless of the branch they target.

Related to crossplane/crossplane#7390

How has this code been tested

I reproduced the failure and the fix in ghcr.io/renovatebot/renovate:43, the same image the Renovate action uses.

On the current code and with gomod2nix's derivations missing from the caches, several of them build in parallel. One creates /homeless-shelter by writing to $HOME, and the next build to start then fails the purity check, which aborts nix run .#tidy. The directory is left behind, so nix run .#generate afterwards fails right away.

With this change, in the same container using our updated entrypoint, both commands complete and the /homeless-shelter directory does not cause any issues ✅

When this is merged, I will run the Renovate action to verify the full flow there too.

I have:

Need help with this checklist? See the cheat sheet.

Renovate's post-upgrade tasks fail intermittently with:

  error: home directory '/homeless-shelter' exists; please remove it to
  assure purity of builds without sandboxing

Renovate then abandons its artifact updates, so a dependency bump lands
with go.mod and go.sum updated but gomod2nix.toml stale, and an
"Artifact update problem" comment appears on the PR.

Nix can't sandbox builds in this container, so it sets
HOME=/homeless-shelter and treats that path staying absent as a purity
check. Any Go build writes to $HOME, creating the directory, and nothing
removes it, so every build after it fails. It only bites when the caches
are missing something: most dependency bumps rebuild only the leaf app
derivation, which runs no Go compiler.

This commit adds a post-build hook that deletes /homeless-shelter after
every build. It also sets max-jobs = 1, since with parallel builds one
can create the directory while another is starting, before the hook has
run.

Related to crossplane/crossplane#7390.

Signed-off-by: Jared Watts <jbw976@gmail.com>
@jbw976
jbw976 requested a review from a team as a code owner July 28, 2026 18:51
@jbw976
jbw976 requested a review from haarchri July 28, 2026 18:51
@coderabbitai

coderabbitai Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The Renovate entrypoint now creates a /homeless-shelter cleanup helper and configures Nix to run builds serially with that helper as a post-build hook.

Changes

Nix Renovate configuration

Layer / File(s) Summary
Create Nix cleanup helper
.github/renovate-entrypoint.sh
Creates an executable helper that removes /homeless-shelter.
Wire cleanup into Nix builds
.github/renovate-entrypoint.sh
Sets max-jobs = 1 and registers the helper as the Nix post-build-hook, replacing automatic parallelism.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related issues

  • crossplane/crossplane#7390 — Directly addresses serialized Nix builds and cleanup of /homeless-shelter.

Suggested reviewers: haarchri

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the Renovate Nix build cleanup fix and fits the length requirement.
Description check ✅ Passed The description directly explains the /homeless-shelter cleanup fix, its rationale, and testing.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Breaking Changes ✅ Passed Only .github/renovate-entrypoint.sh changed; no non-test/generated Go files or exported APIs were modified.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/renovate-entrypoint.sh:
- Around line 34-38: Update the Renovate startup flow in
.github/renovate-entrypoint.sh to invoke
/usr/local/bin/nix-clean-homeless-shelter once before running renovate. Keep the
existing max-jobs and post-build-hook configuration unchanged, ensuring stale
/homeless-shelter state is cleared before the first build.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 8a3e1a2a-e7e7-4e00-b72b-3d240f1e94af

📥 Commits

Reviewing files that changed from the base of the PR and between 600ec54 and 3d51a33.

📒 Files selected for processing (1)
  • .github/renovate-entrypoint.sh

Comment thread .github/renovate-entrypoint.sh

@bobh66 bobh66 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants