Re:The Magic Nix Cache, a GitHub Action for speeding up your...
by biggestlou on Monday June 26, 2023 @05:42PM
(#36486269)
Could you possibly clarify what you mean by "skip those first steps?" Which steps are you referring to?
[ Parent
| on HN ]
Re:The Magic Nix Cache, a GitHub Action for speeding up your...
by iso8859-1 on Monday June 26, 2023 @05:53PM
(#36486374)
Presumably, the Magic Nix Cache speeds up your build by caching the output of the "first steps" (really leaves in a tree of inputs). Otherwise, how would it work? So by steps, I am referring to the steps that your Nix derivation consists of.
Re:The Magic Nix Cache, a GitHub Action for speeding up your...
by biggestlou on Monday June 26, 2023 @06:04PM
(#36486513)
When Nix "realises" a derivation, it realises the entire dependency tree (here, "realises" means either building or fetching, depending on whether a dependency is already in the Nix store). For every single derivation (dependency) in the tree, Nix first calculates what the store path for that dependency would be and then uses that to determine if it's already stored in the Nix store. So it would look at, say, a glibc dependency in a derivation and determine that the Nix store path would be /nix/store/7kn2mkg0g49lfflkdip7i39q3zsck4pc-glibc. If that's already in the Nix store then it doesn't need to build that. And it applies this logic throughout the entire dependency tree. In some cases, the entire dependency tree has already been built and written to the Nix store, in which Nix knows that it doesn't have to build anything. So Nix's caching logic doesn't apply only to the "first steps" of a Nix build (or realisation, to be more specific); it applies to all steps.
Re:The Magic Nix Cache, a GitHub Action for speeding up your...
by grhmc on Monday June 26, 2023 @06:05PM
(#36486526)
Check out https://zero-to-nix.com/concepts/closures and https://zero-to-nix.com/concepts/realisation, which I think add more color to this (and also is largely authored by biggestlou here.)