Install a GitHub repo as a Nix package

Hey there!

I’m trying to replace the provided package for Electron with one from this GitHub repo. I’ve looked into creating an IFD and creating an overlay, the latter of which seems closer to what I’m looking for, although I may just be messing it up entirely. Within my /etc/nixos/configuration.nix, I am installing the base electron_27 from nixpkgs and then attempting to create an overlay like so:

nixpkgs.overlays = [
    # electron replacement with electron-content-security
    ( final: prev:
      {
        electron_27 = prev.electron.overrideAttrs ( old: {
          src = prev.fetchFromGitHub {
            owner = "castlabs";
            repo = "electron-releases";
            rev = "d33e78af7caa061672aa5c5297338432fa98e70b";
            hash = "sha256-0ShJmdsgVrLnerPwaJC6H3VUS8R5Z8qP3ysCI2TgGRU=";
          };
        });
      }
    ) 
  ];

I know that revision is for a different version of Electron (namely 26.6.0) but, to my understanding, that shouldn’t matter?

When running sudo nixos-rebuild switch, I’m met with the following error:

unzip:  cannot find or open /nix/store/x1g8xxar3czgqx4mvna7bg6rbr0jqvq7-source, /nix/store/x1g8xxar3czgqx4mvna7bg6rbr0jqvq7-source.zip or /nix/store/x1g8xxar3czgqx4mvna7bg6rbr0jqvq7-source.ZIP.
error: builder for '/nix/store/1lq70hlsz0n4f8bnfka6ri9zb7pi5va8-electron-26.3.0.drv' failed with exit code 9
error: 1 dependencies of derivation '/nix/store/9wpaycly4wvgcw2va1f4f5w21iqdvhk8-system-path.drv' failed to build
error: 1 dependencies of derivation '/nix/store/ak05ny0px1nbrbc986ig1z75g9snwch2-nixos-system-nixos-23.05.4860.9fb122519e9c.drv' failed to build

The instructions for the repo say to simply install it with NPM, which is not an option for electron development on NixOS (you get an ENOENT error until you delete /node_modules/bin/electron and run nix-shell -p electron in the context terminal, at which point it will allow the electron . command to run). Can anyone provide me with any help as to what I’ve done wrong, or where I should look instead? I’m brand new to NixOS and just started working with it this week. I love the concept and implementation thus far, but I’ll have to distrohop elsewhere if I can’t continue to work on this project unfortunately. Thanks for your time and ample documentation thus far, community!

Not sure about your question, but for npm development, I personally enabled nix-ld module, so that NixOs behaves more like fhs. And then I just do nix-shell -p nodejs_latest and use npm stuff like usual. See my answer here for example of a good list of stuff to install in nix-ld: Different methods to run a non-nixos executable on Nixos - Unix & Linux Stack Exchange It’s maybe not super “pure”, but avoids quite some headache for quick development.

If you want it to be really clean without nix-ld, you might also like to look at nix-dream.