Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/cachix/devenv/llms.txt

Use this file to discover all available pages before exploring further.

Every time you activate a devenv shell, a timestamped symlink is created in $DEVENV_HOME/gc/ (typically ~/.local/share/devenv/gc/) that points to the Nix store path backing that environment. These GC roots prevent Nix from deleting active environments during routine garbage collection — but over time they accumulate and can consume significant disk space.

How Garbage Collection Works

When you run devenv gc, three things happen in order:
1

Remove dangling symlinks

Any symlink in the GC directory whose target no longer exists in the Nix store is deleted.
2

Collect live store paths

The remaining symlinks are resolved to their Nix store paths, representing all currently active environments.
3

Run Nix garbage collection

The resolved store paths are passed to Nix GC, which deletes any store path not reachable from a live GC root.
Only the latest successful invocation per project folder is kept — older generations are cleaned up automatically as part of this process.

Running Garbage Collection

$ devenv gc
It is safe to run at any time. devenv gc only removes store paths that are no longer referenced by any active environment, so your current shells are never affected.

Understanding Nix Store Disk Usage

The Nix store (/nix/store) accumulates build artefacts over time — old package versions, superseded environment builds, and intermediate derivations. devenv gc targets the devenv-specific GC roots; you can also reclaim space from the wider store by running Nix’s own garbage collector directly:
$ nix-collect-garbage
To delete all old profile generations and then collect garbage:
$ nix-collect-garbage -d
Running nix-collect-garbage -d removes all old Nix profile generations across your entire system, not just devenv environments. Make sure you don’t need to roll back any system or home-manager profiles before running it.

Automating Garbage Collection

You can schedule devenv gc to run periodically so disk space is reclaimed automatically. On a Linux system with systemd, for example, add a cron entry or a systemd timer. A simple cron entry that runs weekly:
# Run devenv gc every Sunday at 02:00
0 2 * * 0 devenv gc
On NixOS, nix.gc options let you configure automatic Nix store garbage collection system-wide. Combine that with periodic devenv gc runs for a fully automated clean-up strategy.

Build docs developers (and LLMs) love