input-output-hk / haskell.nix

Alternative Haskell Infrastructure for Nixpkgs
https://input-output-hk.github.io/haskell.nix
Apache License 2.0
556 stars 240 forks source link

GHC 9.2.2 weird spec-core error #1459

Closed ilyakooo0 closed 2 years ago

ilyakooo0 commented 2 years ago

I have no idea what caused this and I don't completely understand what the error is about. Might somehow be related to #1393

> Configuring library for hspec-core-2.9.7..
> Error:
>     The following packages are broken because other packages they depend on are missing. These broken packages must be rebuilt before they can be used.
> installed package ghc-9.2.2 is broken due to missing package exceptions-0.10.4
>
hamishmack commented 2 years ago

Try adding modules = [{ reinstallableLibGhc = true; }]; to your project arguments.

ilyakooo0 commented 2 years ago

When I add that I get:

error: store path '/nix/store/zfh6kicb6q6n1vmyk29piyppbr35blw1-ghc-src' is not allowed to have references
hamishmack commented 2 years ago

Oh interesting. Is there a way I can reproduce this?

ilyakooo0 commented 2 years ago

I'll try to create an example in a couple of hours.

ilyakooo0 commented 2 years ago

https://github.com/ilyakooo0/haskell-nix-1459-repro

nix build with flakes enabled reproduces the error

hamishmack commented 2 years ago
hamish@Hamishs-MBP haskell-nix-1459-repro % git diff
diff --git a/flake.nix b/flake.nix
index d4da8d5..3eb0cf8 100644
--- a/flake.nix
+++ b/flake.nix
@@ -17,7 +17,7 @@
         defaultPackage =
           ((pkgs.haskell-nix.stackProject {
             src = ./.;
-            # modules = [{ reinstallableLibGhc = true; }];
+            modules = [{ reinstallableLibGhc = true; }];
           }).flake { }).packages."foo:exe:foo";
       }
     );
hamish@Hamishs-MBP haskell-nix-1459-repro % nix build --system x86_64-darwin
warning: Git tree '/Users/hamish/iohk/haskell-nix-1459-repro' is dirty
hamish@Hamishs-MBP haskell-nix-1459-repro % ls /nix/store/zfh6kicb6q6n1vmyk29piyppbr35blw1-ghc-src
GIT_COMMIT_ID       MAKEHELP.md     a.out           bindisttest     config.log      configure.ac        ghc         install-sh      llvm-passes     packages
HACKING.md      Makefile        aclocal.m4      boot            config.status       distrib         ghc.mk          libffi          llvm-targets        rts
INSTALL.md      README.md       autom4te.cache      compiler        config.sub      docs            hadrian         libffi-tarballs     m4          rules
LICENSE         VERSION         ax_compare_version.m4   config.guess        configure       driver          includes        libraries       mk          utils
ilyakooo0 commented 2 years ago
~/Downloads/haskell-nix-1459-repro                                                                                                                                 master
❯ git status
On branch master
Your branch is up to date with 'origin/master'.

nothing to commit, working tree clean

~/Downloads/haskell-nix-1459-repro                                                                                                                                 master
❯ nix build --system x86_64-darwin
error: builder for '/nix/store/2xyr79nc2i3qqn6g0pjhsdfq7p793srd-hspec-core-lib-hspec-core-2.9.7.drv' failed with exit code 1;
       last 10 log lines:
       > setting SOURCE_DATE_EPOCH to timestamp 1000000000 of file hspec-core-2.9.7/version.yaml
       > patching sources
       > configuring
       > Configure flags:
       > --prefix=/nix/store/phggqg5r62al775ampk3d0wc5y72j4jg-hspec-core-lib-hspec-core-2.9.7 lib:hspec-core --package-db=clear --package-db=/nix/store/25pyzp88pf2w6fd6p8fnfjzj8k4d3xpy-hspec-core-lib-hspec-core-2.9.7-config/lib/ghc-9.2.2/package.conf.d --exact-configuration --dependency=HUnit=HUnit-1.6.2.0-FzNJY68wMwSEWcgQAeFLE1 --dependency=QuickCheck=QuickCheck-2.14.2-GZ9daWbItQy6pSuyX6iGi4 --dependency=ansi-terminal=ansi-terminal-0.11.1-3Sv0mEgGWIM9GuiSdbqxwx --dependency=call-stack=call-stack-0.4.0-AYcsS0c3gfa1CIsAnIwORr --dependency=clock=clock-0.8.3-IsLXGSnFU5qANe9gET0uLj --dependency=hspec-expectations=hspec-expectations-0.8.2-B1IrLvq7CHFFhfphXIh27u --dependency=quickcheck-io=quickcheck-io-0.2.0-7o2mmbxz9iU6ZFkpHyPumK --dependency=random=random-1.2.1-GVS3E1ReVDf6HZ0wk4OzfO --dependency=setenv=setenv-0.1.1.3-GgDYOYnOiuwGjgKoR4YYPq --dependency=tf-random=tf-random-0.5-8llTtym4rXYA1qwoCoAhgW --dependency=stm=stm-2.5.0.2-EAoDUYdxk5m1W1bPZURyGQ --dependency=Cabal=Cabal-3.6.3.0 --dependency=array=array-0.5.4.0 --dependency=base=base-4.16.1.0 --dependency=binary=binary-0.8.9.0 --dependency=bytestring=bytestring-0.11.3.0 --dependency=containers=containers-0.6.5.1 --dependency=deepseq=deepseq-1.4.6.1 --dependency=directory=directory-1.3.6.2 --dependency=filepath=filepath-1.4.2.2 --dependency=ghc=ghc-9.2.2 --dependency=ghc-bignum=ghc-bignum-1.2 --dependency=ghc-boot=ghc-boot-9.2.2 --dependency=ghc-boot-th=ghc-boot-th-9.2.2 --dependency=ghc-compact=ghc-compact-0.1.0.0 --dependency=ghc-heap=ghc-heap-9.2.2 --dependency=ghc-prim=ghc-prim-0.8.0 --dependency=hpc=hpc-0.6.1.0 --dependency=integer-gmp=integer-gmp-1.1 --dependency=mtl=mtl-2.2.2 --dependency=parsec=parsec-3.1.15.0 --dependency=pretty=pretty-1.1.3.6 --dependency=process=process-1.6.13.2 --dependency=rts=rts --dependency=template-haskell=template-haskell-2.18.0.0 --dependency=terminfo=terminfo-0.4.1.5 --dependency=text=text-1.2.5.0 --dependency=time=time-1.11.1.1 --dependency=transformers=transformers-0.5.6.2 --dependency=unix=unix-2.7.2.2 --dependency=xhtml=xhtml-3000.2.2.1 --with-ghc=ghc --with-ghc-pkg=ghc-pkg --with-hsc2hs=hsc2hs --with-gcc=cc --with-ld=ld --with-ar=ar --with-strip=strip --disable-executable-stripping --disable-library-stripping --disable-library-profiling --disable-profiling --enable-static --enable-shared --disable-coverage --enable-library-for-ghci
       > Configuring library for hspec-core-2.9.7..
       > Error:
       >     The following packages are broken because other packages they depend on are missing. These broken packages must be rebuilt before they can be used.
       > installed package ghc-9.2.2 is broken due to missing package exceptions-0.10.4
       >
       For full logs, run 'nix log /nix/store/2xyr79nc2i3qqn6g0pjhsdfq7p793srd-hspec-core-lib-hspec-core-2.9.7.drv'.
error: 1 dependencies of derivation '/nix/store/x47sb1ciwvcaqrcfrys28krv9k440057-hspec-lib-hspec-2.9.7-config.drv' failed to build
error: 1 dependencies of derivation '/nix/store/lpdpsc2xq1igxc2y86bvn33dzxbk1xdf-hspec-lib-hspec-2.9.7.drv' failed to build
error: 1 dependencies of derivation '/nix/store/wkzs6608kl0cbznh0pg651kszib5b7p2-haskoin-core-lib-haskoin-core-0.21.2-config.drv' failed to build
error: 1 dependencies of derivation '/nix/store/s77n9ydd1bqfrnny8wv69r2d41jzm5k0-haskoin-core-lib-haskoin-core-0.21.2.drv' failed to build
error: 1 dependencies of derivation '/nix/store/9ybgh35710bdwp2zvbzq8mxgq3ivnwyj-foo-exe-foo-0.0.0.drv' failed to build

~/Downloads/haskell-nix-1459-repro                                                                                                                           master ⏱  1s
❯ micro flake.nix

~/Downloads/haskell-nix-1459-repro                                                                                                                   +1 -1   master ⏱  3s
❯ git diff
diff --git a/flake.nix b/flake.nix
index d4da8d5..3eb0cf8 100644
--- a/flake.nix
+++ b/flake.nix
@@ -17,7 +17,7 @@
         defaultPackage =
           ((pkgs.haskell-nix.stackProject {
             src = ./.;
-            # modules = [{ reinstallableLibGhc = true; }];
+            modules = [{ reinstallableLibGhc = true; }];
           }).flake { }).packages."foo:exe:foo";
       }
     );

~/Downloads/haskell-nix-1459-repro                                                                                                                         +1 -1   master
❯ nix build --system x86_64-darwin
warning: Git tree '/Users/iko/Downloads/haskell-nix-1459-repro' is dirty
trace: To make project.stack-nix for haskell-project a fixed-output derivation but not materialized, set `stack-sha256` to the output of the 'calculateMaterializedSha' script in 'passthru'.
trace: To materialize project.stack-nix for haskell-project entirely, pass a writable path as the `materialized` argument and run the 'updateMaterialized' script in 'passthru'.
trace: WARNING: `cleanSourceWith` called on /nix/store/1rr1h9r6ni6igwzanvfc9nhxraz0kp06-source without a `name`. Consider adding `name = "1rr1h9r6ni6igwzanvfc9nhxraz0kp06-source";`
error: store path '/nix/store/zfh6kicb6q6n1vmyk29piyppbr35blw1-ghc-src' is not allowed to have references
(use '--show-trace' to show detailed location information)

~/Downloads/haskell-nix-1459-repro                                                                                                                   +1 -1   master ⏱  6s
❯
hamishmack commented 2 years ago

What nix version? I was using 2.7 I updated to 2.8 and ran nix-store --delete /nix/store/zfh6kicb6q6n1vmyk29piyppbr35blw1-ghc-src and nix build --system x86_64-darwin and it still worked fine.

https://nixos.org/manual/nix/stable/installation/upgrading.html

ilyakooo0 commented 2 years ago

I'm on 2.4

Might be a bug

hamishmack commented 2 years ago

Please try #1461 like this:

diff --git a/flake.lock b/flake.lock
index d3df54f..1c244d6 100644
--- a/flake.lock
+++ b/flake.lock
@@ -171,15 +171,16 @@
         "stackage": "stackage"
       },
       "locked": {
-        "lastModified": 1651367700,
-        "narHash": "sha256-JTSIwNL986NRipZyV++GQ4QoiVoqE2oY0DWhn+LJno0=",
+        "lastModified": 1651547312,
+        "narHash": "sha256-WYiMTDO0FQDv/9r02VkQiKm9t1uiFcQX0sRf7PlmehU=",
         "owner": "input-output-hk",
         "repo": "haskell.nix",
-        "rev": "801310c927bbaab9f83dd0aee75ce959c5f06529",
+        "rev": "2dc74a0b60573af2599e9ad847a982a615301b66",
         "type": "github"
       },
       "original": {
         "owner": "input-output-hk",
+        "ref": "hkm/nix-2.4-fix",
         "repo": "haskell.nix",
         "type": "github"
       }
diff --git a/flake.nix b/flake.nix
index d4da8d5..5d168d9 100644
--- a/flake.nix
+++ b/flake.nix
@@ -2,7 +2,7 @@
   description = "A very basic flake";

   inputs = {
-    haskellNix.url = "github:input-output-hk/haskell.nix";
+    haskellNix.url = "github:input-output-hk/haskell.nix/hkm/nix-2.4-fix";
     nixpkgs.follows = "haskellNix/nixpkgs-unstable";
     flake-utils.url = "github:numtide/flake-utils";
   };
@@ -17,7 +17,7 @@
         defaultPackage =
           ((pkgs.haskell-nix.stackProject {
             src = ./.;
-            # modules = [{ reinstallableLibGhc = true; }];
+            modules = [{ reinstallableLibGhc = true; }];
           }).flake { }).packages."foo:exe:foo";
       }
     );
ilyakooo0 commented 2 years ago

Yup, it works now

Thanks