Once you have a non-trivial Nix flake involving more than the nixpkgs input, you might run into issues where while evaluating, packages that should be in the configured binary caches begin to build locally. This is obviously not what we want; but how do we stop it?
First and foremost, one must understand how the hash of a Nix store path is derived, namely from its inputs. To belabour the point, this means a Nix store path hash changes when its inputs do. This hash can be looked up on configured binary caches, or substituters, to pull the built package from the cache instead of building it locally.
Now how are binary caches actually populated with those packages? Nixpkgs depends on a build tool named Hydra - this populates https://cache.nixos.org on every commit. A similar CI system does the same for most flakes, populating their own caches for their consumers.
Now, when we pull in a flake input, we generally expect to get the same package that was built and pushed in CI - however, because flake inputs have transitive dependencies, chief amongst them being their own nixpkgs input, a very common situation to run into is doing something like the following:
{
inputs.nixpkgs.url = "github:nixos/nixpkgs";
inputs.hyprland.url = "github:hyprwm/hyprland";
inputs.hyprland.inputs.nixpkgs.follows = "nixpkgs";
}
For those uninitiated, this pins the hyprland flake input's OWN nixpkgs input (which is used for library function, package references, etc.) to yours - this is usually done to avoid a whole separate instance of nixpkgs in your nix store for each input, but this runs into a pretty hard to spot trap.
Since derivation hashes are based on their inputs, and hyprland populates hyprland.cachix.org with the packages built against a different revision of nixpkgs, the resultant derivation hashes are completely different from whats on the cache!
How do you fix this? Simple - just don't use inputs.*.follows unless explicitly recommended by the author, or you really know what you're doing, or maybe you just really love wasting electrons
See ya tomorrow