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

Example projects not working #27

Closed
oscar-izval opened this issue Jun 7, 2023 · 7 comments · Fixed by #28
Closed

Example projects not working #27

oscar-izval opened this issue Jun 7, 2023 · 7 comments · Fixed by #28

Comments

@oscar-izval
Copy link

Hi! I'm trying to follow the guide to test the examples provided in the repo, but I'm facing some issues, here's what I've done so far:

  1. Fresh clone of the repo
  2. Run nix build from my-example-haskell-lib-easy/. I get this error:
$ nix build
error: hash mismatch in fixed-output derivation '/nix/store/d6dbmxf60l647hmlfypk409zk1pmg371-source.drv':
         specified: sha256-Hz/xaCoxe4cJBH3h/KIfjzsrEyD915YEVEK8HFR7nO4=
            got:    sha256-ULKUethJNV2/5bs5xMKcPtX3qX10pvyjd5+whVRwVmQ=
error: 1 dependencies of derivation '/nix/store/2il79k0lfzpvjvs97xnn6x0a05asnsls-all-cabal-hashes-component-hspec-2.9.7.drv' failed to build
error: 1 dependencies of derivation '/nix/store/r3bdjfg4yfd87hsjkhm8vhp6j71wl8qi-cabal2nix-hspec-2.9.7.drv' failed to build
(use '--show-trace' to show detailed location information)
  1. Replace sha256 with the one suggested in the error in my-example-haskell-lib-easy/flake.nix#L96:
  2. At this point, after another nix build I get the following (as I originally mentioned in Unordered-Containers error nothunks #25):
$ nix build
warning: Git tree '/Users/oizquierdo/sb/stacklock2nix' is dirty
error: anonymous function at /nix/store/r5r86ssz81zdhmasban29996a4fiilq6-cabal2nix-splitmix-0.1.0.4/default.nix:1:1 called with unexpected argument 'testu01'

       at /nix/store/9qkpbm10iypl7zclprk9r0pwncr0snjk-source/pkgs/development/haskell-modules/make-package-set.nix:97:40:

           96|       # this wraps the `drv` function to add a `overrideScope` function to the result.
           97|       drvScope = allArgs: ensureAttrs (drv allArgs) // {
             |                                        ^
           98|         overrideScope = f:
(use '--show-trace' to show detailed location information)

Other things I've tried or found:

$ cat /nix/store/g18qmc2qzdicd2qns729gcpca2sp9v93-cabal2nix-splitmix-0.1.0.4/default.nix
{ mkDerivation, async, base, base-compat, base-compat-batteries
, bytestring, clock, containers, criterion, deepseq, HUnit, lib
, math-functions, process, random, test-framework
, test-framework-hunit, tf-random, vector
}:
mkDerivation {
  pname = "splitmix";
  version = "0.1.0.4";
  sha256 = "6d065402394e7a9117093dbb4530a21342c9b1e2ec509516c8a8d0ffed98ecaa";
  revision = "1";
  editedCabalFile = "1iqlg2d4mybqwzwp67c5a1yxzd47cbp4f7mrpa6d0ckypis2akl0";
  libraryHaskellDepends = [ base deepseq ];
  testHaskellDepends = [
    async base base-compat base-compat-batteries bytestring containers
    deepseq HUnit math-functions process random test-framework
    test-framework-hunit tf-random vector
  ];
  benchmarkHaskellDepends = [
    base clock containers criterion random tf-random
  ];
  description = "Fast Splittable PRNG";
  license = lib.licenses.bsd3;
}
@cdepillabout
Copy link
Owner

cdepillabout commented Jun 8, 2023

Thanks for the detailed debugging messages!

  1. Run nix build from my-example-haskell-lib-easy/. I get this error:
    $ nix build
    error: hash mismatch in fixed-output derivation '/nix/store/d6dbmxf60l647hmlfypk409zk1pmg371-source.drv':
             specified: sha256-Hz/xaCoxe4cJBH3h/KIfjzsrEyD915YEVEK8HFR7nO4=
                got:    sha256-ULKUethJNV2/5bs5xMKcPtX3qX10pvyjd5+whVRwVmQ=
    error: 1 dependencies of derivation '/nix/store/2il79k0lfzpvjvs97xnn6x0a05asnsls-all-cabal-hashes-component-hspec-2.9.7.drv' failed to build
    error: 1 dependencies of derivation '/nix/store/r3bdjfg4yfd87hsjkhm8vhp6j71wl8qi-cabal2nix-hspec-2.9.7.drv' failed to build

I'm pretty surprised you're seeing this error. I test that my-example-haskell-lib-easy/ builds in CI, it is quite unexpected that you would be having trouble running nix build in that directory. As far as I remember, everything should be correctly pinned so that it "just works".

Is there anything other debugging steps you could think of?

@cdepillabout
Copy link
Owner

Oh, maybe you also changed the resolver: in stack.yaml to an older version?

My guess is that in older stackage resolvers, the splitmix package doesn't take a testu01 argument. Let me see if I can put together a PR to fix (what I think is) the problem you're seeing.

@oscar-izval
Copy link
Author

Oh, maybe you also changed the resolver: in stack.yaml to an older version?

Negative, I'm running nix build from a fresh clone

Is there anything other debugging steps you could think of?

Just tried on another computer (macos x86_64) and same result. The other computer is an M1

$ nix build -L
source> trying https://github.com/commercialhaskell/all-cabal-hashes/archive/9ab160f48cb535719783bc43c0fbf33e6d52fa99.tar.gz
source>   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
source>                                  Dload  Upload   Total   Spent    Left  Speed
source>   0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
source> 100 63.0M    0 63.0M    0     0   634k      0 --:--:--  0:01:41 --:--:--  749k
source> unpacking source archive /private/tmp/nix-build-source.drv-0/9ab160f48cb535719783bc43c0fbf33e6d52fa99.tar.gz
error: hash mismatch in fixed-output derivation '/nix/store/kwr99xys5r3ykbsqa2zvh17mbdpcp9h9-source.drv':
         specified: sha256-Hz/xaCoxe4cJBH3h/KIfjzsrEyD915YEVEK8HFR7nO4=
            got:    sha256-ULKUethJNV2/5bs5xMKcPtX3qX10pvyjd5+whVRwVmQ=
error: 1 dependencies of derivation '/nix/store/63v7n8989gq7kpcw7rx1p37aghq3aprw-all-cabal-hashes-component-hspec-2.9.7.drv' failed to build
error:
       … while calling the 'derivationStrict' builtin

         at //builtin/derivation.nix:9:12: (source not available)

       … while evaluating derivation 'my-example-haskell-app-0.1.0.0'
         whose name attribute is located at /nix/store/9qkpbm10iypl7zclprk9r0pwncr0snjk-source/pkgs/stdenv/generic/make-derivation.nix:270:7

       … while evaluating attribute 'buildInputs' of derivation 'my-example-haskell-app-0.1.0.0'

         at /nix/store/9qkpbm10iypl7zclprk9r0pwncr0snjk-source/pkgs/stdenv/generic/make-derivation.nix:314:7:

          313|       depsHostHost                = lib.elemAt (lib.elemAt dependencies 1) 0;
          314|       buildInputs                 = lib.elemAt (lib.elemAt dependencies 1) 1;
             |       ^
          315|       depsTargetTarget            = lib.elemAt (lib.elemAt dependencies 2) 0;

       (stack trace truncated; use '--show-trace' to show the full trace)

       error: 1 dependencies of derivation '/nix/store/jz0iqyn6irbdm5pkbbamsm9vig852i7h-cabal2nix-hspec-2.9.7.drv' failed to build

@sestrella
Copy link

@cdepillabout I would like to jump in and provide some additional context. I faced the same issues @oscar-izval mentioned before, however, I manage to go a little further by making the following changes:

# my-example-haskell-lib-easy/flake.nix
- rev = "9ab160f48cb535719783bc43c0fbf33e6d52fa99";
- sha256 = "sha256-Hz/xaCoxe4cJBH3h/KIfjzsrEyD915YEVEK8HFR7nO4=";
+ rev = "4018a4b7b6c3d8c0db39b71e6900732399f7c96e";
+ sha256 = "sha256-adFkfnBgV0iTPFUlR9L6EuYFBiZwnTKd2LA8Xv+8PKE";
# nix/build-support/stacklock2nix/cabal2nixArgsForPkg.nix
- "splitmix" = ver: { testu01 = null; };

I think the reason why nix build complains about cabal2nix-splitmix-0.1.0.4/default.nix:1:1 called with unexpected argument 'testu01' on macOS is that this test-suite is only buildable for Linux:

test-suite splitmix-testu01
  if !os(linux)
    buildable: False

Source: https://github.com/haskellari/splitmix/blob/master/splitmix.cabal

Getting rid of the splitmix override for macOS could be a potential solution, however, I found another issue:

error: builder for '/nix/store/q03cfpf7iv8qpvqq3h8plhm94zcv30yp-unliftio-0.2.22.0.drv' failed with exit code 1;
       last 10 log lines:
       >
       >   To rerun use: --match "/UnliftIO.IO.File/writeBinaryFileDurable/default-permissions/"
       >
       > Randomized with seed 1113949765
       >
       > Finished in 7.2448 seconds
       > 118 examples, 2 failures
       > Test suite unliftio-spec: FAIL
       > Test suite logged to: dist/test/unliftio-0.2.22.0-unliftio-spec.log
       > 0 of 1 test suites (0 of 1 test cases) passed.
       For full logs, run 'nix log /nix/store/q03cfpf7iv8qpvqq3h8plhm94zcv30yp-unliftio-0.2.22.0.drv'.
error: 1 dependencies of derivation '/nix/store/qv2ljl8ygw8x5yvhxjh786p7j2bc85k1-conduit-1.3.4.3.drv' failed to build
error: 1 dependencies of derivation '/nix/store/gmm98w8ryssdzywyi1q1z6fhp486gy8r-warp-3.3.21.drv' failed to build
error: 1 dependencies of derivation '/nix/store/c56w38sbl23mn22kaj5283y0ia62gv07-my-example-haskell-lib-0.1.0.0.drv' failed to build
error: 1 dependencies of derivation '/nix/store/3y4vydf73ybx7p9vxfv2ns7ljaxy7jg8-my-example-haskell-app-0.1.0.0.drv' failed to build

I didn't have time to debug this deeper, however, at first glance it looks unrelated to this project

@sestrella
Copy link

Going back to the changes I posted before, I think a better solution for the splitmix override would look something like this:

"splitmix" = ver: 
  if pkgs.stdenv.isLinux then
    { testu01 = null; }
  else
    {};

@cdepillabout
Copy link
Owner

@sestrella

I found another issue:

error: builder for '/nix/store/q03cfpf7iv8qpvqq3h8plhm94zcv30yp-unliftio-0.2.22.0.drv' failed with exit code 1;
      last 10 log lines:
       >
       >   To rerun use: --match "/UnliftIO.IO.File/writeBinaryFileDurable/default-permissions/"
       >
       > Randomized with seed 1113949765
       >
       > Finished in 7.2448 seconds
       > 118 examples, 2 failures
       > Test suite unliftio-spec: FAIL
       > Test suite logged to: dist/test/unliftio-0.2.22.0-unliftio-spec.log
       > 0 of 1 test suites (0 of 1 test cases) passed.
       For full logs, run 'nix log /nix/store/q03cfpf7iv8qpvqq3h8plhm94zcv30yp-unliftio-0.2.22.0.drv'.

I didn't have time to debug this deeper, however, at first glance it looks unrelated to this project

Thanks for reporting this. This looks the same as:

https://github.com/NixOS/nixpkgs/blob/deaae54adcb431bcb333ca6485b025ed17fe877d/pkgs/development/haskell-modules/configuration-darwin.nix#L306-L317

I fixed this in #28 in 889f987. Could you test if this fixes the problem for you?

@cdepillabout
Copy link
Owner

cdepillabout commented Jun 12, 2023

@oscar-izval

In #28 (comment) you say

Same thing on this branch :(

$ nix build
error: hash mismatch in fixed-output derivation '/nix/store/2n8dc0z22c7fvmhhvab28hvdwaf7cb3h-source.drv':
         specified: sha256-MLF0Vv2RHai3n7b04JeUchQortm+ikuwSjAzAHWvZJs=
            got:    sha256-WMkGyt1IFBGQzw4vnCouiiAhPa8BXr7cFM30RZsgvLY=
error: 1 dependencies of derivation '/nix/store/gk8s5df4pwr0ckaidi141krrnl7c6xz6-all-cabal-hashes-component-hspec-2.9.7.drv' failed to build
error: 1 dependencies of derivation '/nix/store/qg8hsw58a81ayqmm583i83grqfs970pp-cabal2nix-hspec-2.9.7.drv' failed to build

I'm not sure what could be going on here. Could you do nix show-derivation on /nix/store/2n8dc0z22c7fvmhhvab28hvdwaf7cb3h-source.drv and show the output here? Maybe also do nix show-derivation on the two other .drv files in the output there.

@sestrella Do you have an idea what could be going on here? In #27 (comment) you say:

I faced the same issues @oscar-izval mentioned before, however, I manage to go a little further by making the following changes:

# my-example-haskell-lib-easy/flake.nix
- rev = "9ab160f48cb535719783bc43c0fbf33e6d52fa99";
- sha256 = "sha256-Hz/xaCoxe4cJBH3h/KIfjzsrEyD915YEVEK8HFR7nO4=";
+ rev = "4018a4b7b6c3d8c0db39b71e6900732399f7c96e";
+ sha256 = "sha256-adFkfnBgV0iTPFUlR9L6EuYFBiZwnTKd2LA8Xv+8PKE";

Is this the change that is necessary to work around the error from @oscar-izval? Do you have an idea why this was necessary?

In #28, as of commit 889f987, the lines of code you're referencing look like:

all-cabal-hashes = final.fetchFromGitHub {
owner = "commercialhaskell";
repo = "all-cabal-hashes";
rev = "f3f41d1f11f40be4a0eb6d9fcc3fe5ff62c0f840";
sha256 = "sha256-MLF0Vv2RHai3n7b04JeUchQortm+ikuwSjAzAHWvZJs=";
};

It sounds like this hash may be incorrect if you're on OSX?

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

Successfully merging a pull request may close this issue.

3 participants