Unnecessary overlay rebuild

I have following overlay for lilypond package, because it’s currently broken. I want to select a version that is not available in the packages.

For some reason when I rebuild my configuration (not touching lilypond at all), it sometimes triggers the compilation of lilypond for no obvious reason. I would expect that once it’s compiled, it stays without compilation until I change URL or version of the package.

How do I prevent these unnecessary recompilations? Thank you!

  final: prev: {
    lilypond = prev.lilypond.overrideAttrs (old: rec {
      version = "2.24.3";
      src = prev.fetchurl {
        url = "http://lilypond.org/download/sources/v${prev.lib.versions.majorMinor version}/lilypond-${version}.tar.gz";
        sha256 = "sha256-3wBfdu969aTNdKEPjnEVJ4t/p58UAYk3tlwQlJjsRL4=";

Did you update Nixpkgs? If any dep of lilypond changes, lilypond will have to be rebuilt.

Yes, I did updated Nixpkgs. I see, so it’s inevitable. I need to find a way how to “store” the built version in a same way as it’s downloaded when using in a normal way. Ideally in a local way, so it’s “re-downloaded” locally without recompiling everything. Which is btw illogical, because the source code didn’t change.

The term/technology you’re looking for is a remote builder and likely a binary cache to go with it.

You’d basically set up your own little hydra.nixos.org and cache.nixos.org which build packages and host the built packages respectively.

For a single application that doesn’t take too long to build, this probably isn’t worth it.

Note that the source code has no special standing in Nix. It’s just an input to the derivation like any other.

In Nix’ model, a derivation changes (and therefore needs to be rebuilt) when any of its inputs change; no matter what they represent.