Nix-store gives bad estimate about hard linking after --gc

When I run nix-store --gc it tells me that I might save a lot of space by hard linking. When I then run nix-store --optimise the resulting gain is much smaller than promised. Is there something I am doing wrong (some nix option or what not) or is the value printed after --gc just a bad estimate?

I just ran the commands again to check and it promises a gain of 70GB but
nothing happens:

$ nix-store --gc
finding garbage collector roots...
deleting garbage...
deleting '/nix/store/trash'
deleting unused links...
note: currently hard linking saves 71673.04 MiB
0 store paths deleted, 0.00 MiB freed
$ nix-store --optimise
0.00 MiB freed by hard-linking 0 files
$ nix-store --gc
finding garbage collector roots...
deleting garbage...
deleting '/nix/store/trash'
deleting unused links...
note: currently hard linking saves 71673.04 MiB
0 store paths deleted, 0.00 MiB freed

I take those messages to mean the opposite, that 71G is already being saved by hard linking, and no additional space is saved by the further nix-store --optimise run. All the duplicate files in your store are already hard linked, there are no further savings to be had.

1 Like

note: currently hard linking saves 71673.04 MiB

Has already saved. Not going to save.

Oh, I was so exited to get back a big chunk of my disk space :frowning:

Now I can be happy that I am not at 123% disk usage instead :smiley:

Thank you for the info!