input-output-hk / haskell.nix

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

Package builds with stack, doesn't build with haskell.nix #2186

Open zmrocze opened 5 months ago

zmrocze commented 5 months ago

This template is a guide only, feel free add or omit sections as appropriate.

Describe the bug

Using:

Haskell source code version locked at:

  1. https://github.com/zmrocze/agda-language-server/tree/c2ae939fcc041bcb1e4a5f1f8bacc88434f49d16

Haskell.nix, system, ghc versions locked at:

  1. https://github.com/zmrocze/agda-language-server.nix/tree/4a8d0beca0c734d2692c4887858ae3438a6ce072

I want to build the package from 1. with haskell.nix. I take it as input in the flake 2. and build it in the most usual way with haskell.nix, see 2.. Running stack build in 1. succeeds but haskell.nix build fails.

Steps To Reproduce

Run

nix build github:zmrocze/agda-language-server.nix\?ref=4a8d0beca0c734d2692c4887858ae3438a6ce072

and observe fail to build, by a failing build of a dependency. You will see something like:

       > buildPhase completed in 5 minutes 46 seconds
       > installing
       > Installing library in /nix/store/c92cq2aa91l26bkr5glkmvfa5qarbdkn-Agda-lib-Agda-2.6.4/lib/x86_64-linux-ghc-9.2.8/Agda-2.6.4-2s4UofYjycP5wyQEx5u0zH
       > Generating Agda library interface files...
       > dist/build/agda/agda: readCreateProcess: posix_spawnp: does not exist (No such file or directory)
       For full logs, run 'nix log /nix/store/n8f4izzq2g7h3vw9df8nrnm57ckq0syw-Agda-lib-Agda-2.6.4.drv'.
error: 1 dependencies of derivation '/nix/store/xa55k3cialzwcql68cz0bzh084fwjgk7-agda-language-server-exe-als-0.2.6.4.0.3.drv' failed to build

Now go to repository 1. The package there builds with stack but it needs some packages in path when building the final package "agda-language-server". Therefore I provide shell.nix and instruct stack to use these deps with nix: ... lines in stack.yaml. Enter the nix shell and run stack build: nix-shell -c "stack build". The build succeeds.

The dependency on agda-lib-agda which fails when building with haskell.nix, builds with stack or is provided from snapshot. Therefore haskell.nix does something incompatible with to stack build.

Important: Note that eventhough for the stack build to succeed I need the nix shell - The haskell.nix fails earlier (when building agda-lib dependency). Therefore I cannot even get to debugging the agda-language-server build, because haskell.nix does something else than stack. Otherwise overriding buildInputs of my derivation with the packages needed in the shell.nix would likely fix the problem.

Expected behavior

The package builds with haskell.nix. Or it fails at building the package agda-language-server and I can fix the build by overriding the derivations buildInputs - to mimick entering shell.nix in 1. before running stack build.

zmrocze commented 5 months ago

Found that you guys (iog i mean) have hit this problem yourself, exactly that problem:

https://github.com/IntersectMBO/plutus/blob/b97e8be50470065f37948f62dcaa7d67f71b9a39/nix/agda-project.nix#L14

Which is good because i have a fix.

But also a second time that bug is discovered.

michaelpj commented 5 months ago

The bug is arguably in agda, in that it does not build properly when using per-component builds.

stale[bot] commented 1 month ago

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.