[Nix-dev] garbage-collection of the last 'n' generations

Profpatsch mail at profpatsch.de
Thu Mar 30 16:01:47 CEST 2017


On 17-03-30 02:42pm, Azul wrote:
> Hi there,
> 
> I would like to cleanup my oldest  'n' nix generations.
> 
> nix-collect-garbage seems to only provide me with a older than 'n' days
> option.
> 
> Any quick hacks to clean everything but keep my recent  'n' generations ?

Remove all system links from /nix/var/nix/profiles that you don’t want
    for i in $(seq 100 142); do rm "/nix/var/nix/profiles/system-$i-link"; done

Then perform a garbage collection
    nix-store --gc

This works for all kinds of profiles (e.g. the result link from nix-build).

-- 
Proudly written in Mutt with Vim on NixOS.
Q: Why is this email five sentences or less?
A: http://five.sentenc.es
May take up to five days to read your message. If it’s urgent, call me.


More information about the nix-dev mailing list