Hi! I have noticed that my NixOS tends to build a derivation on my machine while my NixOS configuration does not explicitly override it.
I would like to find why it builds on my machine on every update, basically when I bump the nixpkgs pin.
As a first sanity check, I would like to make sure it’s this dependency that deviates from the cache, i.e. only this derivation does not have a match in the binary cache but its dependencies do.
Before I start digging manually with nix-tree and nix path-info ( Is it possible to query the binary cache? ), I wanted to make sure I am not missing a more principled way that would be quicker and less painful.
Also, I am 100% open to another plan (X/Y problem, you know) that would also answer the original question, though I’d be still interested in effective ways to compare dependency tree vs cache.
I’d be interested in the answer to your original question, but just in case, here are some things to check that might solve your other problem:
Which nixpkgs branch are you using? You should use either nixos-unstable or nixos-25.11 (current latest stable). These branches only “advance” once they are built in the central cache.
Which package is building locally? Looking at the source for that derivation may give some hints about how something in your configuration causes a cache miss.
You should be able to check your local system closure’s runtime dependencies, and filter for those that were built locally - they will have the “ultimate” flag, indicating that they are trusted because they were built locally.
Note that a lot of small derivations will always be built locally, it’ll help to know which one keeps rebuilding. Once you’ve found it, you can check on hydra to see if it successfully builds:
If it does and you want to find out why it’s different, figure out the upstream package’s derivation path and use nix-diff to analyze the differences in their build closures. With flakes I would do nix eval –raw .#nixosConfigurations.hostname.pkgs.packageHere.drvPath