Closed domenkozar closed 1 year ago
@sorki any ideas?
To reproduce:
$ nix-store -r /nix/store/00mzv9k8gjw0pgzla4ysraq5kdsjbkb2-libffi-3.4.2
$ nix-store --dump /nix/store/00mzv9k8gjw0pgzla4ysraq5kdsjbkb2-libffi-3.4.2 > store
$ nix-shell -p "haskellPackages.ghcWithPackages (pkgs: [pkgs.hnix-store-core])"
$ ghci
ghci> import System.Nix.Nar
ghci> import System.IO
ghci> handle <- openFile "hnix" WriteMode
ghci> buildNarIO narEffectsIO "/nix/store/00mzv9k8gjw0pgzla4ysraq5kdsjbkb2-libffi-3.4.2" handle
$ diff -y <(xxd store) <(xxd hnix)
Most likely we need to sort the files/directories list or something trivial like that.
Symlinks to the directories seems to be the reason of this issue. MRE:
$ cat default.nix
let
pkgs = import <nixpkgs> {};
in
derivation {
system = "x86_64-linux";
name = "test";
builder = "${pkgs.bash}/bin/bash";
args = [ ./builder.sh ];
coreutils = pkgs.coreutils;
}
$ cat ./builder.sh
export PATH="$coreutils/bin"
mkdir $out
mkdir $out/1
echo 11 > $out/1/1
ln -s $out/1 $out/link1
$ nix-build
this derivation will be built:
/nix/store/67rnrqr2dwz9nqdv0awqrnvpv1gwjz2b-test.drv
building '/nix/store/67rnrqr2dwz9nqdv0awqrnvpv1gwjz2b-test.drv'...
/nix/store/bxgc56np7s0h35xl2dwmkcd65hxpxxqf-test
$ nix-store --dump /nix/store/bxgc56np7s0h35xl2dwmkcd65hxpxxqf-test > store
$ cabal repl hnix-store-core
ghci> import System.Nix.Nar
ghci> import System.IO
ghci> withFile "hnix" WriteMode \handle -> buildNarIO narEffectsIO "/nix/store/bxgc56np7s0h35xl2dwmkcd65hxpxxqf-test" handle
$ diff -y <(xxd hnix-store-core/hnix) <(xxd store)
@sorki any chance you can make a release?
Yep! Thanks for the fixes!
Most likely we need to sort the files/directories list or something trivial like that.
I have just spent whole day trying to debug an issue in my own implementation of mkStorePath
. Then I found this comment and it turned out to be it!!
Thank you for posting it :100:
For /nix/store/00mzv9k8gjw0pgzla4ysraq5kdsjbkb2-libffi-3.4.2, there's a mismatch in hashes comparing to what
nix-store --dump
and nar streaming would generate.This hints there's bug somewhere.