Automatically cleans up old Nix garbage collection roots based on configurable policies to free up disk space.
angrr is a Nix tool that automatically removes old garbage collection roots based on user-defined policies. It solves the problem of disk space being wasted by stale Nix store paths, especially for users of nix-direnv where inactive project roots are not cleaned up. The tool helps maintain an efficient Nix store by periodically deleting unused roots.
Heavy Nix and NixOS users, particularly those using nix-direnv, who need automated cleanup of old GC roots to free up disk space. System administrators managing Nix-based development environments will also benefit.
Developers choose angrr for its highly configurable policies, seamless integration with direnv, and set-and-forget automation. It provides more control and flexibility compared to built-in Nix garbage collection, especially for cleaning profile generations and temporary roots.
Auto Nix GC Root Retention
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Users can define custom retention periods and rules for different GC root types, such as temporary roots from nix-direnv or profile generations, as shown in the detailed configuration examples in the README.
Once configured, angrr runs periodically via the NixOS module or other setups, automatically removing stale roots without manual intervention, ideal for set-and-forget maintenance.
The tool provides a direnv library that automatically touches GC roots when projects are accessed, ensuring active environments are retained, as demonstrated in the integration examples.
The --dry-run option allows previewing deletions without making changes, reducing the risk of accidental data loss during policy testing.
The version in the stable nixos-25.11 channel is outdated (v0.1.1) and lacks features like profile generation cleaning, forcing reliance on flakes or unstable sources.
Setting up custom policies requires understanding regex patterns and Nix store paths, which can be steep and error-prone for users unfamiliar with Nix internals.
The automatic touching of GC roots during direnv loading can introduce latency, especially in projects with many store paths, despite optimizations like ignoring .git directories.
For most use cases, nix-direnv's built-in refresh functionality is sufficient, making angrr an unnecessary addition unless addressing specific edge cases like touching roots outside .direnv.