jonascarpay / template-haskell

batteries-included nix-based haskell project template
BSD 3-Clause "New" or "Revised" License
61 stars 10 forks source link

Error when running nix-shell #13

Closed Kozaky closed 2 years ago

Kozaky commented 2 years ago

When following the guide with the new Mac M1 I encountered the following error:

   After searching the rest of the dependency tree exhaustively, these were the
   goals I've had most trouble fulfilling: template-haskell

   error: attribute _shellFor_ missing

   at /nix/store/4sr22fkdl7y0nhhzm036ga8n3vzrzgj6-source/overlays/haskell.nix:654:18:

      653|                   selectedCrossProjects;
      654|               in rawProject.hsPkgs.shellFor (args' // {
         |                  ^
      655|                   # Add inputs from the cross compilation shells

   … while evaluating the attribute 'hsPkgs.shellFor'

   at /nix/store/4sr22fkdl7y0nhhzm036ga8n3vzrzgj6-source/overlays/haskell.nix:522:43:

      521|               project = addProjectAndPackageAttrs rec {
      522|                   inherit (pkg-set.config) hsPkgs;
         |                                           ^
      523|                   inherit pkg-set;

   … while evaluating 'shellFor'

   at /nix/store/4sr22fkdl7y0nhhzm036ga8n3vzrzgj6-source/overlays/haskell.nix:633:24:

      632|             #
      633|             shellFor = shellArgs:
         |                        ^
      634|               let

   … from call site

   at /Users/juliogc/Documents/dev/template-haskell/shell.nix:13:1:

       12| in
       13| hsPkgs.shellFor {
         | ^
       14|   withHoogle = true;`

I have tried to update the commit for Haskell.nix but that does not seem to fix the problem. Any ideas?

jonascarpay commented 2 years ago

Judging from the first line, it's a cabal dependency issue that prevents Haskell.nix from generating a project. The template-haskell there refers to the actual template-haskell Haskell package, not this repo. Can you post the entire log and/or your cabal file?

Kozaky commented 2 years ago

The cabal file is the same one used in the repository. I changed the name of the project and now it seems it is working… I don’t know if it is related tho.

Thank you @jonascarpay

jonascarpay commented 2 years ago

Ohhhhh, I get what's going on, the project itself was named template-haskell, which caused a collission with the actual upsteam template-haskell package, which this project's name is a pun on. Maybe I should add a check for that in the wizard.sh script...

Kozaky commented 2 years ago

Yeah, that could be a good idea, since it is the actual name of your repo :D

Btw, I also noticed that even after configuring the binary cache, nix is building ghc and it takes quite a while. Do you know if there is any solution for this? As far as I know, the version used in this project should be cached for aarch64-darwin, but it does not seem to work

jonascarpay commented 2 years ago

That's odd, maybe try bumping haskell.nix? Change the pin to a commit ideally a couple of days old, and see if that helps.

Kozaky commented 2 years ago

I am using the flake branch right now and even after running “nix flake update”, I still have to spend hours compiling the ghc, I think the problem is with the M1 architecture tho

jonascarpay commented 2 years ago

Even an M1 can't compile GHC in a reasonable timeframe huh 🙃 you're probably right that its an architecture thing but regardless make sure you use a commit that's a couple of days old since its happened to me before that the most recent one isn't cached yet

Kozaky commented 2 years ago

I will give it a try. Thanks for your help, Jonas 😊

jonascarpay commented 2 years ago

The OP issue here was addressed in 0e5a421f4dba7821aa0fe7444723e2d0d51054b8