Git Product home page Git Product logo

Comments (5)

andreabedini avatar andreabedini commented on August 15, 2024 1

@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.

from haskell.nix.

andreabedini avatar andreabedini commented on August 15, 2024 1

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.

from haskell.nix.

nomeata avatar nomeata commented on August 15, 2024

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?

from haskell.nix.

nomeata avatar nomeata commented on August 15, 2024

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" ];
~

from haskell.nix.

stale avatar stale commented on August 15, 2024

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.

from haskell.nix.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.