Skip to content

Conversation

@cole-h
Copy link
Member

@cole-h cole-h commented Jan 20, 2026

Filter out all existing /nix mount point entries and prelude comments, then always append exactly one new fstab entry to ensure at most one /nix entry in the output.

Forward-ported from NixOS/nix-installer#55

Description
Checklist
  • Formatted with cargo fmt
  • Built with nix build
  • Ran flake checks with nix flake check
  • Added or updated relevant tests (leave unchecked if not applicable)
  • Added or updated relevant documentation (leave unchecked if not applicable)
  • Linked to related issues (leave unchecked if not applicable)
Validating with install.determinate.systems

If a maintainer has added the upload to s3 label to this PR, it will become available for installation via install.determinate.systems:

curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix/pr/$PR_NUMBER | sh -s -- install

Summary by CodeRabbit

  • Bug Fixes
    • Always ensures exactly one /nix filesystem entry in system config, removing duplicate or outdated entries.
    • Improves cleanup of old /nix lines and treats a missing config file as empty.
    • Writes updates atomically and preserves trailing newline to avoid partial or malformed configs.

✏️ Tip: You can customize this high-level summary in your review settings.

Filter out all existing /nix mount point entries and prelude comments,
then always append exactly one new fstab entry to ensure at most one
/nix entry in the output.
@cole-h cole-h requested a review from grahamc January 20, 2026 15:26
@coderabbitai
Copy link

coderabbitai bot commented Jan 20, 2026

📝 Walkthrough

Walkthrough

This change updates macOS fstab entry creation to always remove nix-installer prelude comments and any existing /nix mount lines, then unconditionally append a single new /nix fstab entry; revert logic similarly detects and drops /nix lines using ASCII-whitespace splitting.

Changes

Cohort / File(s) Change Summary
macOS fstab entry management
src/action/macos/create_fstab_entry.rs
Rewrote execute to filter out prelude comments and any existing /nix mount lines, always push a single new fstab entry, ensure trailing newline before atomic write; updated revert cleanup to detect /nix via split_ascii_whitespace.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested labels

upload to s3

Suggested reviewers

  • grahamc
  • colemickens

Poem

🐇 I hop through fstab, nibbling old lines away,
Toss out the clutter, then plant one new stay.
No more checking twice, a fresh /nix in sight—
A tidy mount for dawn, soft and bright!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix: prevent duplicate /nix entries in fstab' directly and concisely describes the main change in the pull request: filtering out existing /nix mount points and ensuring exactly one /nix entry is present in fstab.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

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

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@src/action/macos/create_fstab_entry.rs`:
- Around line 85-92: The filter closure in create_fstab_entry.rs currently
checks for the second field using line.split(&[' ', '\t']).nth(1), which fails
on lines with multiple or leading separators; update the condition in the
closure (the filter handling "Remove any existing /nix mount point entries") to
use line.split_whitespace().nth(1) == Some("/nix") so the second fstab field is
parsed robustly and existing /nix entries are reliably detected and removed.

@cole-h cole-h enabled auto-merge (squash) January 20, 2026 15:43
@cole-h cole-h merged commit 849af1e into main Jan 20, 2026
19 checks passed
@cole-h cole-h deleted the fixup-duplicate-nix-fstab-entries branch January 20, 2026 15:43
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.

4 participants