Nix: Suggestion: don't hardlink symlinks

Created on 20 Mar 2019  路  2Comments  路  Source: NixOS/nix

Currently, nix-store --optimise treats identical symlinks just like identical regular files: it replaces them with hardlinks to each other. While this is technically correct, hardlinked symlinks are unusual enough to cause problems with buggy tools or nonstandard filesystems. They're also nonportable, needing workarounds for Darwin and IllumOS.

I personally ran into problems when using BusyBox tar on /nix/store, because it didn't handle hardlinked symlinks properly (fixed in BusyBox 1.29).

The benefits of hardlinking symlinks seem pretty small. On my machine, even optimistically assuming we save 4KiB for each symlink replaced with a hardlink, this only reduces the size of the store by 1.5%. I suggest removing this functionality and leaving symlinks unchanged.

Most helpful comment

Additionally, this saves a nontrivial amount of inodes.

All 2 comments

I'm not so sure about this, 4 KiB per symlink really adds up. For example, my NixOS system-path is 123 MiB because it contains almost 29500 symlinks. So the system-paths of a couple of NixOS generations can easily add up to multiple gigabytes...

Additionally, this saves a nontrivial amount of inodes.

Was this page helpful?
0 / 5 - 0 ratings