dream2nix icon indicating copy to clipboard operation
dream2nix copied to clipboard

Binary hashes are missing

Open tobiasBora opened this issue 3 years ago • 10 comments

Thanks first for this promising project… unfortunately I can't make it work. Here is a very basic project built on electron (just taken from the quickstart web page):

$ cd tmp && git clone https://github.com/tobiasBora/quickstart-electron
$ nix flake init -t github:nix-community/dream2nix#simple
$ nix eval --impure --raw --expr 'builtins.currentSystem' > ./nix_systems && git add ./nix_systems
$ nix flake show
$ nix build .#default
warning: Git tree '/tmp/quickstart-electron' is dirty
error: Electron binary hashes are missing for required version 19.0.9
       Please add the hashes in the override below the origin of this error.
       To get the hashes, execute:
       /nix/store/x6qa4ickfvbagkp9zj86ac49s6ffghvb-nodejs/electron/print-hashes.sh 19.0.9
(use '--show-trace' to show detailed location information
$ /nix/store/x6qa4ickfvbagkp9zj86ac49s6ffghvb-nodejs/electron/print-hashes.sh 19.0.9
error: unable to download 'https://atom.io/download/electron/v19.0.9/node-v19.0.9-headers.tar.gz': HTTP error 403 ('Forbidden')

       response body:

       <?xml version="1.0" encoding="UTF-8"?>
       <Error><Code>AccessDenied</Code><Message>Access Denied</Message><RequestId>W44G2TW1WQEQYV9Y</RequestId><HostId>ijUyhkPzI3jD7+MnmrB4A7amot/QQTZlsLMB/z6AQM7qoInwWb7pCRT+KT6Ym9JYzvv/sb7MDog=</HostId></Error>

tobiasBora avatar Jul 25 '22 11:07 tobiasBora

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/cant-setup-development-with-electron-error-spawn-enoent/18497/5

nixos-discourse avatar Jul 25 '22 11:07 nixos-discourse

The problem with the script receiving the electron binary hashes is fixed by now.

The hashes need to be added to this file: https://github.com/nix-community/dream2nix/blob/main/overrides/nodejs/default.nix#L180

DavHau avatar Aug 13 '22 11:08 DavHau

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/cant-setup-development-with-electron-error-spawn-enoent/18497/7

nixos-discourse avatar Aug 13 '22 11:08 nixos-discourse

Thanks, I can confirm that print-hash works but I'm not sure to understand where to write the overwrite: should I fork this project or can I somehow do that purely locally? Also any reason dream2nix does not come with this hash already?

tobiasBora avatar Aug 24 '22 14:08 tobiasBora

Also meanwhile I tried to change the electron version to 20.0.1 (since I saw that it was in the list of hashes) in the package.json before running npm i --package-lock-only but it fails

$ nix build .#default
warning: Git tree '/tmp/quickstart-electron' is dirty
error: attribute 'electron_20' missing

       at /nix/store/3akswl509msksq037fps8mzb5m66ba7z-source/src/subsystems/nodejs/builders/granular/default.nix:204:14:

          203|         then null
          204|         else pkgs."electron_${electronVersionMajor}".headers;
             |              ^
          205|
       Did you mean one of electron_10, electron_11, electron_12, electron_13 or electron_14?
(use '--show-trace' to show detailed location information)

any idea how to solve this?

Note that if I change the version to 14.2.0 it does work! :-D However I'd love to learn how to install an arbitrary version of electron and co.

tobiasBora avatar Aug 24 '22 14:08 tobiasBora

Currently you need to fork dream2nix and update the hash entries in https://github.com/nix-community/dream2nix/blob/0131c22c369f8c4c661aea7a395e94669a7f5974/overrides/nodejs/default.nix#L180 We should add a better way to override these hashes though. Also we should add a script that updates the hashes of all minor versions automatically.

DavHau avatar Aug 25 '22 13:08 DavHau

I see, thanks. And any idea why electron 20 is not working despite a hash entry? One can't use electron if it's not manually packaged into NixOs?

tobiasBora avatar Aug 26 '22 09:08 tobiasBora

Yes, I think at least a package of the same major version must exist in nixpkgs, otherwise it won't work. We could improve that of course.

DavHau avatar Aug 30 '22 10:08 DavHau

So does that mean that if I specify, say, version 20.1 and nixpkgs only packages version 20.0, then the project would use 20.0?

tobiasBora avatar Aug 30 '22 10:08 tobiasBora

No, it means it would produce the error you posted above and not build anything. You probably just have to update the nixpkgs input of the dream2nix flake

DavHau avatar Aug 31 '22 10:08 DavHau

Fixing issue https://github.com/nix-community/dream2nix/issues/268 will solve that problem

DavHau avatar Nov 09 '22 19:11 DavHau

Thanks!

tobiasBora avatar Nov 09 '22 19:11 tobiasBora