Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hash mismatch for node-gyp #6

Open
niklaskorz opened this issue Mar 16, 2023 · 2 comments
Open

Hash mismatch for node-gyp #6

niklaskorz opened this issue Mar 16, 2023 · 2 comments

Comments

@niklaskorz
Copy link

Trying to set up yarnpnp2nix in https://github.com/niklaskorz/puredit/tree/yarnpnp2nix. There, building nix build .#example leads to the following error:

error: hash mismatch in fixed-output derivation '/nix/store/lrn7xkr2d0d0ikkiix534zqgs54274v0-node-gyp-9.3.1-43540bab9c.drv':
         specified: sha512-Rq/Fv8Ya1YML4urA/z6/BEmHhMBTqGFKD+1P/u7f4RuqEUiulhyyMkylVqHPp7mlBRobRZEwiPosvDZDo7qSVw==
            got:    sha512-050SzpW2p/TcC3FmCzOVwPGmRUxVQXTdylIroIB2yJ3Q9Z6TXiiKOeSZvIWwfQtsNrCKd2eRvyShZPxSiGiNGg==
error: 1 dependencies of derivation '/nix/store/i2h53i1j6165skmmrfmnlm8f9p77ydii-puredit-example-0.0.0-eb98272acc.drv' failed to build

The system is aarch64-darwin.

@niklaskorz
Copy link
Author

niklaskorz commented Mar 16, 2023

Just saw this in the yarn.lock pull request (#4):

If you get hash mismatches, the dependency probably is a native module or unplugged (has postinstall scripts). Install the Yarn plugin as directed above or manually set the shouldBeUnplugged attribute in packageOverrides.

I guess this applies to the current state of master too?

Edit: No, does not seem to be the case (it's already set in yarn-manifest.nix). The hashes of all unplugged packages seem to be wrong.

Edit 2: Ok, it's not unplugged packages in particular, there are some unplugged and some pnp packages with hash mismatches...

@madjam002
Copy link
Owner

For unplugged modules, the hash is guessed and stored in yarn-manifest.nix simply by hashing the directory in the Yarn unplugged directory using the same algo that Nix uses. Because of this it's only stored for the current platform as well. For a lot of modules this works fine, but for modules like node-gyp there are subtle differences when building in Nix vs just using Yarn which will cause the hash to be wrong.

You should override the hashes with what Nix is saying the real hash is like so:

For PNP packages the hash should be correct as it's just based on the checksum of the packages from yarn.lock, if not then there may be a bug somewhere.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants