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 on nixpkgsSrc #1648

Closed
toonn opened this issue Sep 8, 2022 · 7 comments
Closed

Hash mismatch on nixpkgsSrc #1648

toonn opened this issue Sep 8, 2022 · 7 comments

Comments

@toonn
Copy link
Contributor

toonn commented Sep 8, 2022

error: hash mismatch in file downloaded from 'https://github.com/NixOS/nixpkgs/archive/110a2c9ebbf5d4a94486854f18a37a938cfacbbb.tar.gz':
         specified: sha256:0v12ylqxy1kl06dgln6h5k8vhlfzp8xvdymljj7bl0avr0nrgrcm
         got:       sha256:1mf8fkdxbk6bwv0gvk1kyh5307wl71ifl7lnzqvs1z1mk1kbhg0g

       … while realising the context of a path

       at /nix/store/j5hw2a8l4w788bya2yg3ibcqh57n7gip-source/default.nix:9:24:

            8|     };
            9|   pkgs = args.pkgs or (import nixpkgsSrc {});
             |                        ^
           10|   flake-compat =

       … while realising the context of a path

       at /nix/store/j5hw2a8l4w788bya2yg3ibcqh57n7gip-source/default.nix:15:10:

           14|     };
           15|   self = import flake-compat {
             |          ^
           16|     # We bypass flake-compat's rootSrc cleaning by evading its detection of this as a git

       … while evaluating anonymous lambda

       at /nix/store/j5hw2a8l4w788bya2yg3ibcqh57n7gip-source/default.nix:1:1:

            1| {...}@args:
             | ^
            2|

       … from call site

       at /Users/toonn/src/nix-config/haskell.nix/nixpkgs.nix:2:16:

            1| let
            2|   haskellNix = import (builtins.fetchTarball
             |                ^
            3|     ( "https://github.com/input-output-hk/haskell.nix/archive/"

       … while evaluating the file '/Users/toonn/src/nix-config/haskell.nix/nixpkgs.nix':

       … while evaluating anonymous lambda

       at /Users/toonn/src/bfpt/default.nix:1:1:

            1| { pkgs ? import ~/src/nix-config/haskell.nix/nixpkgs.nix
             | ^
            2| , compiler-nix-name ? "ghc902"

       … from call site

This is happening for me on x86_64-darwin. A common source of hash mismatches on Darwin is HFS+, which is case-insensitive by default. But this is just a tarball, so a single file and I don't believe that can make the difference.

@michaelpj
Copy link
Collaborator

This isn't really anything to do with haskell.nix, though?

@toonn
Copy link
Contributor Author

toonn commented Sep 8, 2022

That depends. This hash is specified by the haskell.nix project in its default.nix. If x86_64-darwin is considered a supported system then it is a bug in haskell.nix.

@toonn
Copy link
Contributor Author

toonn commented Sep 8, 2022

I've been looking into this more. It doesn't reproduce on NixOS with Nix 2.3.16 nor Nix 2.11.0, aarch64-darwin with Nix 2.8.1 nor x86_64-darwin with Nix 2.10.3 on APFS.

So it seems pretty specific to my setup.

I've checked all the filenames in nixpkgs for case collisions or differences under NFC/NFD but this hasn't turned up anything.

I'm pretty puzzled 😕

@hamishmack
Copy link
Collaborator

But this is just a tarball, so a single file and I don't believe that can make the difference.

I think that nix might extract the files before hashing so that the source does not matter (tarballs and fetchgit for instance get the same hash if all the files match).

@toonn
Copy link
Contributor Author

toonn commented Sep 8, 2022

Clever helped me troubleshoot this further. Turns out a single bit was flipped in a hash in a package description. So this is entirely on my hardware corrupting a file during fetching or unpacking or something.

Sorry for the noise!

@toonn toonn closed this as completed Sep 8, 2022
@hamishmack
Copy link
Collaborator

See NixOS/nix#847 (comment) and NixOS/nix#2475

My guess is that a unicode character slipped into the nixpkgs source and picked a commit while it was still in there. Hopefully someone has removed it. Let's try bumping the bootstrap nixpkgs to our 22.05 pin.

hamishmack added a commit that referenced this issue Sep 8, 2022
Making it match the current 22.05 pin in flake.lock.

Was going to do this because of #1648, but might save some people a nixpkgs download so let's do it anyway.
hamishmack added a commit that referenced this issue Sep 9, 2022
* Bump nixpkgs pin used in default.nix

Making it match the current 22.05 pin in flake.lock.

Was going to do this because of #1648, but might save some people a nixpkgs download so let's do it anyway.

* Fix test issue

* Use flake.lock

* Use flake.lock
@toonn
Copy link
Contributor Author

toonn commented Sep 9, 2022

@hamishmack, thanks for the response. That was my original suspicion but it turned out not to be true. As I said in my previous comment, this was entirely on my hardware. A single bit flipped in the fetched and unpacked source, changing a "p" to a "q" in a hash in a random package in pkgs. This meant the NAR for that source was in fact different and causing a "legitimate" hash mismatch.

I hope this didn't cause too much undue work on your part! ❤️

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

3 participants