You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Separate static libraries to dev outputs automatically #164141
Looking at space used by nix packages, it seems there's a lot of packages that used Nx space due to having static libraries in out/lib outputs. The first such package I found is llvm.lib used by mesa: it consumes ~300 MB while most of the space is used by static libraries that are helpful only while building something, shared libraries in the package are only around ~100 MB, so it's grown around 3x by that issue. Then, when I started looking at all static libraries in /nix/store with find, rav1e stands out from all other packages. Entire consumed space by rav1e is 89M, librav1e.a is 81M while librav1e.so.0.5.1 is only 3,2M. The package is around 10X bigger than if static libraries were separated and 25X bigger than if there was a lib output with only shared library.
My /nix/store (and nix-store -qR /run/current-system | xargs du -csh | sort -h) is 12GB after nix-collect-garbage -d and I'm trying to understand why it's so big while a similar configuration with other distros would consume a way less space...
Notify maintainers
@lovek323@7c6f434c@dtzWill@primeos for LLVM, it seems rav1e has no maintainers and I don't know who to mention for a generic solution across all the packages...
changed the title [-]Separate static libraries to dev packages automatically[/-][+]Separate static libraries to dev outputs automatically[/+]on Mar 14, 2022
Haskell packages are another big source of static libraries.
IIRC the haskell libraries are statically linked even if the resulting binaries are not (dynamically linked against C libraries), so this seems another waste of space.
@rnhmjoj Haskell (GHC) libraries can be linked into binaries either dynamically or statically, as desired, it’s just that nearly every library or compiler change amounts to an ABI incompatibility, so the traditional (outside of Nix) benefit of transparent upgrades does not apply, only that of sharing read-only pages. I don’t know which way Nix links by default. (Glibc is always linked dynamically.) Of course, the .a files are as large and as useless at runtime as for any other language that uses them.
Activity
ilya-fedin commentedon Mar 14, 2022
Summing up all static libraries on my system, it seems they consume 523M
[-]Separate static libraries to dev packages automatically[/-][+]Separate static libraries to dev outputs automatically[/+]rnhmjoj commentedon Mar 16, 2022
Haskell packages are another big source of static libraries.
IIRC the haskell libraries are statically linked even if the resulting binaries are not (dynamically linked against C libraries), so this seems another waste of space.
waldheinz commentedon Jun 2, 2022
For LLVM in particular I recently did this:
1748887
But I agree that a generic solution would be nice, I started hacking on a hook doing just that but patching the cmake target files is not trivial.
alexshpilkin commentedon Jun 2, 2022
@rnhmjoj Haskell (GHC) libraries can be linked into binaries either dynamically or statically, as desired, it’s just that nearly every library or compiler change amounts to an ABI incompatibility, so the traditional (outside of Nix) benefit of transparent upgrades does not apply, only that of sharing read-only pages. I don’t know which way Nix links by default. (Glibc is always linked dynamically.) Of course, the
.afiles are as large and as useless at runtime as for any other language that uses them.Artturin commentedon Jun 22, 2023
What should be the behaviour of
lib.getLib, it's used to sometimes .a files ex:nixpkgs/pkgs/servers/invidious/lsquic.nix
Lines 85 to 98 in faef939
ilya-fedin commentedon Jun 22, 2023
replace it by getDev?
nixos-discourse commentedon Sep 23, 2026
This issue has been mentioned on NixOS Discourse. There might be relevant details there:
https://discourse.nixos.org/t/visualizing-nix-closures/80102/4