explaingit

mic92/fast-nix-gc

Analysis updated 2026-05-18

17RustAudience · ops devopsComplexity · 4/5Setup · moderate

TLDR

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.

Mindmap

mindmap
  root((repo))
    What it does
      Faster nix gc
      Faster store optimise
      NixOS module
    Tech stack
      Rust
      Nix
      NixOS
    Use cases
      Free disk space
      Dedupe store files
      Scheduled cleanup
    Audience
      Nix users
      DevOps

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Speed up periodic Nix store garbage collection on machines with large stores

USE CASE 2

Deduplicate files in the Nix store faster using hardlink-based optimization

USE CASE 3

Add a NixOS module to run garbage collection and optimization on an automatic schedule

USE CASE 4

Free disk space by deleting old profile generations down to a target size

What is it built with?

RustNixNixOS

How does it compare?

mic92/fast-nix-gcatelico/gdstyleathxrvx/spear
Stars171717
LanguageRustRustRust
Setup difficultymoderateeasymoderate
Complexity4/52/52/5
Audienceops devopsdeveloperdeveloper

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · moderate Time to first run · 30min

Requires Nix or NixOS already installed, building without flakes needs default.nix.

In plain English

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.

Copy-paste prompts

Prompt 1
Help me set up the fast-nix-gc NixOS module to run garbage collection weekly and keep at least 50G free.
Prompt 2
Explain how fast-nix-gc's CSR adjacency list approach makes Nix garbage collection faster than the stock nix-collect-garbage.
Prompt 3
Show me how to build fast-nix-gc from source using nix build or cargo.
Prompt 4
What NixOS module options does fast-nix-optimise support and how do I configure a schedule for it?

Frequently asked questions

What is fast-nix-gc?

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.

What language is fast-nix-gc written in?

Mainly Rust. The stack also includes Rust, Nix, NixOS.

How hard is fast-nix-gc to set up?

Setup difficulty is rated moderate, with roughly 30min to a first successful run.

Who is fast-nix-gc for?

Mainly ops devops.

Open on GitHub → Explain another repo

This repo across BitVibe Labs

Verify against the repo before relying on details.