Repository navigation
Closed
Labels
0.kind: bugSomething is broken
Description
Describe the bug
I tried to use nix-prefetch-git to check out nixpkgs while using the --deepClone options. The resulting sha256 hash is not the correct one to use with nixpkgs.fetchgit.
Steps To Reproduce
I wrote a bash script that produces the issue on my machine.
#!/usr/bin/env sh
set -x
URL='https://github.com/NixOS/nixpkgs.git'
OUTPUT_FROM_PREFETCH=$(nix-prefetch-git --deepClone "${URL}")
SHA256_AS_CALCULATED_BY_PREFETCH=$(echo "${OUTPUT_FROM_PREFETCH}" | jq -r '.sha256')
REVISION=$(echo "${OUTPUT_FROM_PREFETCH}" | jq -r '.rev')
HASH_IN_SRI_FORMAT=$(nix hash to-sri sha256:${SHA256_AS_CALCULATED_BY_PREFETCH} | sed -e 's/^sha256\-//')
nix-build --no-out-link --expr "with import <nixpkgs> {};
fetchgit
{ url = \"${URL}\"; rev = \"${REVISION}\"; sha256 = \"${HASH_IN_SRI_FORMAT}\"; deepClone = true;}
"
When run this on my machine the following output is produced:
$ sh test-prefetch-git.sh
+ URL=https://github.com/NixOS/nixpkgs.git
++ nix-prefetch-git --deepClone https://github.com/NixOS/nixpkgs.git
Initialized empty Git repository in /tmp/nix-shell.zYwbSx/git-checkout-tmp-eYcwHIbd/nixpkgs/.git/
remote: Enumerating objects: 49668, done.
remote: Counting objects: 100% (49668/49668), done.
remote: Compressing objects: 100% (32180/32180), done.
remote: Total 49668 (delta 1794), reused 38869 (delta 1372), pack-reused 0
Receiving objects: 100% (49668/49668), 33.85 MiB | 7.76 MiB/s, done.
Resolving deltas: 100% (1794/1794), done.
From https://github.com/NixOS/nixpkgs
* branch 164e44e62faf175771a3ea905876945529259ee6 -> FETCH_HEAD
Updating files: 100% (30098/30098), done.
Switched to a new branch 'fetchgit'
removing `.git'...
warning: unknown setting 'experimental-features'
git revision is 164e44e62faf175771a3ea905876945529259ee6
path is /nix/store/m5gny1r98spjwqpcc2abnamdxa3g2wql-nixpkgs
git human-readable version is -- none --
Commit date is 2022-04-10 09:33:57 -0500
hash is 0mlbkq3q9yppw6dm7wsk8kvvwwvxrxcrv69nqy167dgypy4zq0hs
+ OUTPUT_FROM_PREFETCH='{
"url": "https://github.com/NixOS/nixpkgs.git",
"rev": "164e44e62faf175771a3ea905876945529259ee6",
"date": "2022-04-10T09:33:57-05:00",
"path": "/nix/store/m5gny1r98spjwqpcc2abnamdxa3g2wql-nixpkgs",
"sha256": "0mlbkq3q9yppw6dm7wsk8kvvwwvxrxcrv69nqy167dgypy4zq0hs",
"fetchLFS": false,
"fetchSubmodules": false,
"deepClone": true,
"leaveDotGit": false
}'
++ echo '{
"url": "https://github.com/NixOS/nixpkgs.git",
"rev": "164e44e62faf175771a3ea905876945529259ee6",
"date": "2022-04-10T09:33:57-05:00",
"path": "/nix/store/m5gny1r98spjwqpcc2abnamdxa3g2wql-nixpkgs",
"sha256": "0mlbkq3q9yppw6dm7wsk8kvvwwvxrxcrv69nqy167dgypy4zq0hs",
"fetchLFS": false,
"fetchSubmodules": false,
"deepClone": true,
"leaveDotGit": false
}'
++ jq -r .sha256
+ SHA256_AS_CALCULATED_BY_PREFETCH=0mlbkq3q9yppw6dm7wsk8kvvwwvxrxcrv69nqy167dgypy4zq0hs
++ echo '{
"url": "https://github.com/NixOS/nixpkgs.git",
"rev": "164e44e62faf175771a3ea905876945529259ee6",
"date": "2022-04-10T09:33:57-05:00",
"path": "/nix/store/m5gny1r98spjwqpcc2abnamdxa3g2wql-nixpkgs",
"sha256": "0mlbkq3q9yppw6dm7wsk8kvvwwvxrxcrv69nqy167dgypy4zq0hs",
"fetchLFS": false,
"fetchSubmodules": false,
"deepClone": true,
"leaveDotGit": false
}'
++ jq -r .rev
+ REVISION=164e44e62faf175771a3ea905876945529259ee6
++ nix hash to-sri sha256:0mlbkq3q9yppw6dm7wsk8kvvwwvxrxcrv69nqy167dgypy4zq0hs
++ sed -e 's/^sha256\-//'
+ HASH_IN_SRI_FORMAT=GgL8ib/+tWOCxzaZnVnPfXO+90RT81Ob4ff6hAeei1Y=
+ nix-build --no-out-link --expr 'with import <nixpkgs> {};
fetchgit
{ url = "https://github.com/NixOS/nixpkgs.git"; rev = "164e44e62faf175771a3ea905876945529259ee6"; sha256 = "GgL8ib/+tWOCxzaZnVnPfXO+90RT81Ob4ff6hAeei1Y="; deepClone = true;}
'
this derivation will be built:
/nix/store/gkgsanlrsicgasmn2b8fkwpzax82sln7-nixpkgs-164e44e.drv
building '/nix/store/gkgsanlrsicgasmn2b8fkwpzax82sln7-nixpkgs-164e44e.drv'...
exporting https://github.com/NixOS/nixpkgs.git (rev 164e44e62faf175771a3ea905876945529259ee6) into /nix/store/hls8xpfghx84bih44480hlx00in4g36v-nixpkgs-164e44e
Initialized empty Git repository in /nix/store/hls8xpfghx84bih44480hlx00in4g36v-nixpkgs-164e44e/.git/
remote: Enumerating objects: 49668, done.
remote: Counting objects: 100% (49668/49668), done.
remote: Compressing objects: 100% (32131/32131), done.
remote: Total 49668 (delta 1841), reused 38936 (delta 1421), pack-reused 0
Receiving objects: 100% (49668/49668), 33.83 MiB | 597.00 KiB/s, done.
Resolving deltas: 100% (1841/1841), done.
From https://github.com/NixOS/nixpkgs
* branch 164e44e62faf175771a3ea905876945529259ee6 -> FETCH_HEAD
Updating files: 100% (30098/30098), done.
Switched to a new branch 'fetchgit'
Enumerating objects: 49668, done.
Counting objects: 100% (49668/49668), done.
Compressing objects: 100% (33552/33552), done.
Writing objects: 100% (49668/49668), done.
Total 49668 (delta 1015), reused 47661 (delta 0), pack-reused 0
Enumerating objects: 49668, done.
Nothing new to pack.
error: hash mismatch in fixed-output derivation '/nix/store/gkgsanlrsicgasmn2b8fkwpzax82sln7-nixpkgs-164e44e.drv':
specified: sha256-GgL8ib/+tWOCxzaZnVnPfXO+90RT81Ob4ff6hAeei1Y=
got: sha256-TImVBL7mn+eFshu6vodRxL+jSHgT5g6RHk/ohm3HDPI=Expected behavior
I would expect that using the hash given by nix-prefetch-git --deepClone would work for fetchgit { deepClone=true; ...}.
Screenshots
n/a
Notify maintainers
I have no idea who the maintainer of this is. Sorry. If community members know who is responsible for this code, feel free to add them.
Metadata
Please run nix-shell -p nix-info --run "nix-info -m" and paste the result.
[user@system:~]$ nix-shell -p nix-info --run "nix-info -m"
- system: `"x86_64-linux"`
- host os: `Linux 5.10.106, NixOS, 21.11 (Porcupine)`
- multi-user?: `no`
- sandbox: `yes`
- version: `nix-env (Nix) 2.5.0pre20211206_d1aaa7e`
- channels(me): `""`
- channels(root): `"nixos-22.05pre345234.b2737d4980a"`
- nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`Metadata
Metadata
Assignees
Labels
0.kind: bugSomething is broken
Activity
seppeljordan commentedon Jun 24, 2022
bump