Skip to content

Setup automatic garbage collection for NixOS - #6

Open
JPyke3 wants to merge 1 commit into
mainfrom
claude/nixos-garbage-collection-UVOHl
Open

Setup automatic garbage collection for NixOS#6
JPyke3 wants to merge 1 commit into
mainfrom
claude/nixos-garbage-collection-UVOHl

Conversation

@JPyke3

@JPyke3 JPyke3 commented Jan 7, 2026

Copy link
Copy Markdown
Owner

Add daily nix garbage collection with store optimization:

  • Conservative 14-day retention for most systems
  • Aggressive 7-day retention for china (125GB drive constraint)

Add daily nix garbage collection with store optimization:
- Conservative 14-day retention for most systems
- Aggressive 7-day retention for china (125GB drive constraint)
@claude

claude Bot commented Jan 7, 2026

Copy link
Copy Markdown

Pull Request Review: Automatic Garbage Collection for NixOS

Overview

This PR adds automatic garbage collection and store optimization to all NixOS systems with system-specific overrides. The changes are well-structured and address a real need for disk space management.


✅ Strengths

  1. Good separation of concerns: Default config in shared configuration.nix, china-specific override in china/configuration.nix
  2. Clear documentation: Comments explain the rationale ("conservative defaults", "aggressive for 125GB drive")
  3. Store optimization: Including nix.optimise.automatic = true is excellent for long-term space savings
  4. Conservative defaults: 14-day retention is reasonable for most systems

🔍 Code Quality & Best Practices

systems/nixos/configuration.nix:86-95

  • ✅ Configuration is clear and well-commented
  • ✅ Uses nix.gc.dates = "daily" which is appropriate for automated cleanup

systems/nixos/china/configuration.nix:9-10

  • ✅ Override pattern is correct (nix.gc.options only)
  • ✅ 7-day retention makes sense for 125GB constraint

💡 Suggestions & Considerations

1. Timing Coordination (Minor)

The garbage collection runs "daily" but does not specify a time. Consider setting explicit timing to avoid conflicts with system.autoUpgrade which runs at 03:00.

2. Store Optimization Timing (Minor)

nix.optimise.automatic runs after every build. Consider using scheduled optimization instead to reduce I/O during builds, especially on china.

3. Steam Deck (japan) Consideration (Question)

Does japan (Steam Deck OLED) have storage constraints? SD cards can fill quickly with game data. Consider if it needs a china-style override.

4. Darwin System (Info)

This PR only affects NixOS systems. The darwin (Mac Mini) system does not get these settings. Consider adding GC configuration there as well if needed.


🔒 Security & Performance

  • Security: No security concerns - GC is a safe operation
  • Performance: Minimal impact - runs during low-activity hours
  • ⚠️ Disk I/O: nix.optimise.automatic can be I/O-intensive on china during builds

🧪 Test Coverage

Recommended manual testing before merge:

  • Verify systemd timers are created correctly
  • Check GC options are applied per-system
  • Test on china to ensure 7-day retention works

📊 Impact Assessment

System Before After Notes
china No auto-GC 7-day GC Critical - fixes 125GB constraint
norway No auto-GC 14-day GC Good preventative maintenance
austria No auto-GC 14-day GC Helpful for Apple Silicon storage
japan No auto-GC 14-day GC May need shorter retention for SD card
darwin No auto-GC No change Consider adding later

✅ Verdict

LGTM with minor suggestions - This PR is ready to merge as-is. The suggestions above are optional improvements, not blockers.


Great work on proactively managing disk space! This will prevent future "out of space" issues on china.

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