Electron rebuilds completely with every update

I’m using some electron based apps on nixos-unstable and electron-unwrapped is recompiled withe every update. I’m having this problem with heroic games launcher, bitwarden-desktop, signal-desktop, and deltachat-desktop. Every update does the long and resource-intensive recompilation of multiple electron-unwrapped versions. Are they not built for the main binary cache?

Do you by any chance set a nix version other than nixStable in an overlay in your config?

I used to do this to work around a bug in the nix executable at the time, and it started to trigger electron rebuilds. I think it happened via a dependency on nix in pkgs/build-support/node/fetch-npm-deps/default.nix and I fixed it for a while, but the fix itself broke at some point. But as nix was fixed as well at that time I just dropped the overlay completely and I don’t have an up-to-date workaround.

Because I trigged my own curiosity - electron now also depends on fetch-yarn-deps so my workaround was no longer sufficient. This now seems to work though:

  overlay-nixVersion = final: prev: {
    nix = final.nixUnstable;

    # Prevent extensive rebuild of electron
    inherit (final.callPackages "${inputs.nixpkgs}/pkgs/build-support/node/fetch-npm-deps" { nix = final.nixStable; })
      fetchNpmDeps prefetch-npm-deps;
    inherit (final.callPackages "${inputs.nixpkgs}/pkgs/build-support/node/fetch-yarn-deps" { nix = final.nixStable; })
      fetchYarnDeps prefetch-yarn-deps;
    inherit (final.callPackages "${inputs.nixpkgs}/pkgs/tools/package-management/nix-prefetch-scripts" { nix = final.nixStable; })
      nix-prefetch-git;  # more prefetch scripts exist and depend on nix

Of course if you were not using an overlay for nix in the first place this is all useless to you, but maybe someone else will find it useful.

What are your overlays and do you allow any insecure packages?

Yes, that could be it. Thank you. I used the unstable NIx version because of an error a while ago.

It seems to be a problem with the Nix unstable overlay.