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

Conflicting plan-sha256 reported #2001

Closed
nomeata opened this issue Jul 15, 2023 · 5 comments
Closed

Conflicting plan-sha256 reported #2001

nomeata opened this issue Jul 15, 2023 · 5 comments
Labels
bug Something isn't working wontfix

Comments

@nomeata
Copy link
Contributor

nomeata commented Jul 15, 2023

I am using haskell.nix to provide (among other things) Windows builds of a project of mine, and this usually works great.

Since the latest upgrade, though, I have trouble with the windows build: It keeps telling me to switch the plan-sha256 between two values.

To reproduce check out entropia/tip-toi-reveng#290 at revision a64a59b587980896fa3e87de9163ed61bb86412f and run

nix-build -A windows-exe --extra-substituters https://tttool.cachix.org/\ https://cache.iog.io --extra-trusted-public-keys tttool.cachix.org-1:e/5HpIa6ZqwatH07kmO7di1p9K+AMrgkNHl/OGUUMzU=\ hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ= --arg checkMaterialization true

The hash is stored at

https://github.com/entropia/tip-toi-reveng/blob/a64a59b587980896fa3e87de9163ed61bb86412f/default.nix#L103

One of the plan hashes is the same as the linux one, so maybe a currentSystem snuck in somewhere where it shouldn’t?

If I set the hash to null, the build succeeds.

Not sure if it is relevant, but maybe it’s somehow related to how I help haskell.nix not get stuck on system depenedencies hier:

https://github.com/entropia/tip-toi-reveng/blob/a64a59b587980896fa3e87de9163ed61bb86412f/default.nix#L15-L19

A hint would be appreciated!

@nomeata nomeata added the bug Something isn't working label Jul 15, 2023
@nomeata
Copy link
Contributor Author

nomeata commented Jul 16, 2023

Adding --show-trace shows that somehow c2hs is involved:

       … while evaluating the attribute 'buildPackages.c2hs.components.exes.c2hs'

So here is a theory: It tries to build c2hs as a build tool in the non-cross way, and in order to do so it checks the build plan of that tool?

@nomeata
Copy link
Contributor Author

nomeata commented Jul 20, 2023

I found this work-around; not sure how idiomatic that is:

diff --git a/default.nix b/default.nix
index 6f06728..487dfc3 100644
--- a/default.nix
+++ b/default.nix
@@ -53,6 +53,9 @@ let
       modules = [{
         # smaller files
         packages.tttool.dontStrip = false;
+        packages.proteaaudio.components.library.build-tools = pkgs.lib.mkForce [
+          pkgs.buildPackages.haskellPackages.c2hs
+        ];
       }] ++
       pkgs.lib.optional pkgs.hostPlatform.isMusl {
         packages.tttool.configureFlags = [ "--ghc-option=-static" ];
~

@andreabedini
Copy link
Member

@nomeata Thanks for the updates. I haven't had the chance of looking into this but I just want to say it didn't go unnoticed.

@andreabedini
Copy link
Member

Ok, I spent some times on this and I haven't got the bottom of it unfortunately. There must be something wrong with which pkgs is being used for the evaluating plan.

If I reproduced this correctly:

❯ nix-build -A windows-exe --arg checkMaterialization true
...
       > Calculated hash for haskell-project-plan-to-nix-pkgs was not 0674c017qxng0xil4yi4wsf2kr7yb9dyzpzxq7jd50dflzvm3qzz. New hash is :
       >     plan-sha256 = "0jmcpd8l6smj0zqkx4cx6ma2v3cvxmwws0s92ssrc6ginpis3gkb";
       For full logs, run 'nix log /nix/store/swa7qajzskxhad4pvbng24aamkls5v9b-haskell-project-plan-to-nix-pkgs.drv'.

❯ nix log /nix/store/swa7qajzskxhad4pvbng24aamkls5v9b-haskell-project-plan-to-nix-pkgs.drv
Changes to haskell-project-plan-to-nix-pkgs not reflected in plan-sha256
diff -ru /nix/store/giba13w486j458p7l3jwg0rqc2zvw4fd-haskell-project-plan-to-nix-pkgs/default.nix /nix/store/6c8mdm4a5a151nxn8yjm04mc1a2hq7zz-haskell-project-plan-to-nix-pkgs/default.nix
...
Calculated hash for haskell-project-plan-to-nix-pkgs was not 0674c017qxng0xil4yi4wsf2kr7yb9dyzpzxq7jd50dflzvm3qzz. New hash is :
    plan-sha256 = "0jmcpd8l6smj0zqkx4cx6ma2v3cvxmwws0s92ssrc6ginpis3gkb";

The script calculateMaterializedSha computes the hash of calculateNoHash, but if I call it

❯ nix-build -A windows-exe.project.plan-nix.passthru.calculateMaterializedSha
/nix/store/9wazjkh39l2bi8pwgrx6d9sq5j24v9fk-calculateSha

❯ /nix/store/9wazjkh39l2bi8pwgrx6d9sq5j24v9fk-calculateSha
0674c017qxng0xil4yi4wsf2kr7yb9dyzpzxq7jd50dflzvm3qzz

which is the hash we have passed! Let's see how the check is done:

❯ nix derivation show /nix/store/swa7qajzskxhad4pvbng24aamkls5v9b-haskell-project-plan-to-nix-pkgs.drv^* | jq -r '.[].env.buildCommand'
ERR=$(mktemp -d)/errors.txt
NEW_HASH=$(/nix/store/g3bd66c23mzspxdqik6hr4ppgal3k08x-calculateSha)
if [[ 0674c017qxng0xil4yi4wsf2kr7yb9dyzpzxq7jd50dflzvm3qzz != $NEW_HASH ]]; then
  echo Changes to haskell-project-plan-to-nix-pkgs not reflected in plan-sha256
  diff -ru /nix/store/giba13w486j458p7l3jwg0rqc2zvw4fd-haskell-project-plan-to-nix-pkgs /nix/store/6c8mdm4a5a151nxn8yjm04mc1a2hq7zz-haskell-project-plan-to-nix-pkgs || true
  echo "Calculated hash for haskell-project-plan-to-nix-pkgs was not 0674c017qxng0xil4yi4wsf2kr7yb9dyzpzxq7jd50dflzvm3qzz. New hash is :" >> $ERR
  echo "    plan-sha256 = \"$NEW_HASH\";"                      >> $ERR
else
  echo plan-sha256 used for haskell-project-plan-to-nix-pkgs is correct
fi
if [[ -e $ERR ]]; then
  cat $ERR
  false
else
  cp -Lr /nix/store/giba13w486j458p7l3jwg0rqc2zvw4fd-haskell-project-plan-to-nix-pkgs $out
  # Make sure output files can be removed from the sandbox
  chmod -R +w $out
fi

where NEW_HASH is

❯ /nix/store/g3bd66c23mzspxdqik6hr4ppgal3k08x-calculateSha
0jmcpd8l6smj0zqkx4cx6ma2v3cvxmwws0s92ssrc6ginpis3gkb

which is the other hash.

Surely we should not say Calculated hash for haskell-project-plan-to-nix-pkgs was not 0674c017qxng0xil4yi4wsf2kr7yb9dyzpzxq7jd50dflzvm3qzz if project.plan-nix.passthru.calculateMaterializedSha returns that exact hash.

One thing I don't understand is that looking at

diff -ru /nix/store/giba13w486j458p7l3jwg0rqc2zvw4fd-haskell-project-plan-to-nix-pkgs /nix/store/6c8mdm4a5a151nxn8yjm04mc1a2hq7zz-haskell-project-plan-to-nix-pkgs

one can identify

diff -ru ${calculateUseHash} ${calculateNoHash} || true

  • calculateUseHash -> /nix/store/giba13w486j458p7l3jwg0rqc2zvw4fd-haskell-project-plan-to-nix-pkgs
  • calculateNoHash -> /nix/store/6c8mdm4a5a151nxn8yjm04mc1a2hq7zz-haskell-project-plan-to-nix-pkgs

Whose definition is

calculateNoHash = derivation;
calculateUseHash =
# Use `cp -Lr` here to get rid of symlinks so we know the result
# can be safely materialized (no symlinks to the store).
runCommand name hashArgs ''
cp -Lr ${derivation} $out
# Make sure output files can be removed from the sandbox
chmod -R +w $out
'';

One would expect calculateUseHash to be a wrapper around calculateNoHash but

❯ nix derivation show /nix/store/giba13w486j458p7l3jwg0rqc2zvw4fd-haskell-project-plan-to-nix-pkgs | jq -r '.[].env.buildCommand'
cp -Lr /nix/store/20s0023rxwcik9qj5yww8avz156i821h-haskell-project-plan-to-nix-pkgs $out
# Make sure output files can be removed from the sandbox
chmod -R +w $out

which is "the other" plan.

Maybe @hamishmack has better insight.

Copy link

stale bot commented Nov 21, 2023

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Nov 21, 2023
@stale stale bot closed this as completed Jan 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working wontfix
Projects
None yet
Development

No branches or pull requests

2 participants