3 ms·
It does. Nix has an extremely powerful (and flexible) caching system. Not to mention popular caching systems like cachix that are easy to integrate into your sy
by slabity 3y ago
It does. Nix has an extremely powerful (and flexible) caching system. Not to mention popular caching systems like cachix that are easy to integrate into your system.
Unlike most other packaging systems though, Nix packages are rebuilt when there's changes to any of their dependencies. This results in a huge amount of storage data used in their caches compared to other systems. Not to mention the compute power required to rebuild those packages.
For example, let's say something like `glibc` updated with a new patch. Every single package that has `glibc` as a dependency needs to be rebuilt, along with every package that has any of those packages as a dependency. This could easily cause the rebuild of tens of thousands of packages, even if they are only dynamically linking to it.
- pxc 3y agoMaybe we should be using something like Guix grafts to save not just rebuild time, but space (and thus money).
- dlahoda 3y agonix has security patch tech.
- slabity 3y agoGuix's graft system is a hack specifically made to get security updates out ASAP. They should really only be seen as a last resort because it circumvents the primary benefit of using Guix as a functional build system (pure, reproducible builds). I'm not sure if Nix has a similar system. IMHO I'd prefer to see compile-time caches like ccache or sccache be better integrated into Nix while still providing the guarantees that a functional build system provides. That alone would save massive amounts of compute power when rebuilding packages, as you'd essentially only need to recompile the files that change in a package. Not only on continuous build systems like Nix's Hydra, but also when just rebuilding packages locally. This won't solve the storage cost issue, but would definitely alleviate compute costs.
- xyzzy_plugh 3y agoI've been curious but haven't seen any compile-time cache, even with an unsafe build. What's the state of the art for this today?
- slabity 3y agoIt's possible to bring something like `ccache` into your system's Nix sandbox. However, that change in the sandbox means all your packages have different hashes and you lose the ability to pull from upstream caches. The result would be rebuilding every single package when trying to update your system. Not a fun time. The preferred way to do this is to override `stdenv` with `ccacheStdenv` on the individual packages that would actually benefit from the compile-time caching. Such as for large packages that you already have overrides for, or for nightly packages that get updated extremely frequently and don't have the chance to be cached upstream (such as firefox-nightly). The NixOS Wiki has a pretty good article on this: https://nixos.wiki/wiki/CCache https://nixos.wiki/wiki/CCache I personally use this for any packages I override in an overlay to reduce build times significantly.
- dizhn 3y agoOpenSuse tumbleweed also has to do this. I don't know what happens with NixOS in such cases but with tw we have to download and install all those new packages too. There has been 2 times in the last year we had to download 2-3 TB of packages. While we're talking about opensuse, perhaps there's a way for them to exist on the opensuse build system?