Analysis updated 2026-05-18
Speed up periodic Nix store garbage collection on machines with large stores
Deduplicate files in the Nix store faster using hardlink-based optimization
Add a NixOS module to run garbage collection and optimization on an automatic schedule
Free disk space by deleting old profile generations down to a target size
| mic92/fast-nix-gc | atelico/gdstyle | athxrvx/spear | |
|---|---|---|---|
| Stars | 17 | 17 | 17 |
| Language | Rust | Rust | Rust |
| Setup difficulty | moderate | easy | moderate |
| Complexity | 4/5 | 2/5 | 2/5 |
| Audience | ops devops | developer | developer |
Figures from each repo's GitHub metadata at analysis time.
Requires Nix or NixOS already installed, building without flakes needs default.nix.
fast-nix-gc is a faster replacement for two built-in Nix package manager maintenance commands: nix-collect-garbage, which deletes unused files from the Nix store, and nix-store --optimise, which saves disk space by merging identical files together. Nix is a package manager used mostly by Linux and macOS developers who want reproducible software builds. The standard garbage collector checks every stored file one at a time using a database query, which becomes slow once a system has around 100,000 stored files. This tool instead loads the whole list of files and their relationships into memory once, then walks through them using simple integer references, which is far faster. On a real machine with about 30,000 files that were no longer needed, this cut the time for a trial run from about 20 seconds to about 1 second. Actually deleting files and cleaning up afterward runs in parallel across multiple CPU cores. The companion tool, fast-nix-optimise, finds duplicate files and replaces the copies with hard links to save disk space, in a way that stays fully compatible with the original nix-store --optimise, so both tools can be used interchangeably. It skips rechecking files it already knows are deduplicated, making repeated runs roughly twice as fast as the original on a store that has already been cleaned once. Both tools share a lock file so they never conflict with each other or with Nix itself while it is building software. The project includes a module for NixOS, a Linux distribution built around Nix, letting users schedule automatic cleanup and optimization runs and configure options like how much free space to keep or how old generations must be before deletion. The project is written in Rust and can be built with the standard nix build command or with cargo. Real-world timing tests the author shared show speedups ranging from roughly 1.5 times faster on tiny systems up to over 100 times faster on large build servers with heavily used Nix stores.
fast-nix-gc is a faster, drop-in replacement for Nix's built-in garbage collection and store optimization commands, cutting cleanup times from minutes to seconds on large Nix stores.
Mainly Rust. The stack also includes Rust, Nix, NixOS.
Setup difficulty is rated moderate, with roughly 30min to a first successful run.
Mainly ops devops.
This repo across BitVibe Labs
Verify against the repo before relying on details.