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

First attempt at getting haskell.nix to work with nixpkgs provided compiler #1833

Closed
wants to merge 3 commits into from

Conversation

andreabedini
Copy link
Member

@andreabedini andreabedini commented Feb 2, 2023

Addresses #1565, #1531

Test with

$ nix build -f test/with-nixpkgs-ghc/default.nix

You can compare with haskell.nix provided ghc doing

$ nix build -f test/with-nixpkgs-ghc/default.nix --arg with-nixpkgs false

It doesn't work yet.

error: builder for '/nix/store/kc6s5i90sg8f9vcc84bmba724v98rhzc-Cabal-lib-Cabal-3.6.3.0.drv' failed with exit code 1;
       last 10 log lines:
       > filepath >=1.3.0.1 && <1.5,
       > mtl >=2.1 && <2.3,
       > parsec >=3.1.13.0 && <3.2,
       > pretty >=1.1.1 && <1.2,
       > process >=1.1.0.2 && <1.7,
       > text >=1.2.3.0 && <1.3 || ==2.0.*,
       > time >=1.4.0.1 && <1.13,
       > transformers ==0.3.* || >=0.4.1.0 && <0.6,
       > unix >=2.6.0.0 && <2.8
       >
       For full logs, run 'nix log /nix/store/kc6s5i90sg8f9vcc84bmba724v98rhzc-Cabal-lib-Cabal-3.6.3.0.drv'.
error: 1 dependencies of derivation '/nix/store/cyj07lpxk87ild1lzppg3861bk1my5kh-hpack-exe-hpack-0.35.0.drv' failed to build
error: 1 dependencies of derivation '/nix/store/0dfk0qj15vml9b8x07lw80a0lb1h4wb5-hpack-lib-hpack-0.35.0-config.drv' failed to build
error: 1 dependencies of derivation '/nix/store/sddb67idq4lhkkk51z5nagjz3wp8qqcd-hpack-lib-hpack-0.35.0.drv' failed to build
error: 1 dependencies of derivation '/nix/store/yq8vnjaw5lwqsgj16bpwrq63lrwzx4qk-nix-tools-lib-nix-tools-0.1.0.0-config.drv' failed to build
error: 1 dependencies of derivation '/nix/store/k0di5bkr6zk309r361zrfhvzzw9ffzpa-nix-tools-lib-nix-tools-0.1.0.0.drv' failed to build
error: 1 dependencies of derivation '/nix/store/zsxmd6rbh0jjfjxvnjy5p0r7nfwlz5j1-nix-tools.drv' failed to build
error: 1 dependencies of derivation '/nix/store/dk9842nlgawms6a57ydnsxfkq29zmb6v-haskell-project-plan-to-nix-pkgs.drv' failed to build

@andreabedini
Copy link
Member Author

Ok, ghc is missing the evalDeps and exactDeps folders, which we rely on to create the configure flags in the *-config/configure-flags derivations. Haskell.nix creates those folders during ghc bootstrap.

This seems to work. Revert a couple of unnecessary changes.
@angerman
Copy link
Collaborator

angerman commented Feb 5, 2023

Question: what do we do if the compiler does not exist in the nixpkgs used with Haskell.nix? As they are orthogonal, I don't think there is any guarantee about the GHC we can expect form nixpkgs?

Edit: to be clear, I'm not against this. I just want to know how we expect to deal with this in a way that the user can make some sense of.

@junjihashimoto
Copy link

If not, it will probably fail with an error.
Now when there is no cache, it forces to build ghc, then we wait for a long time.

@andreabedini
Copy link
Member Author

Well the short answer is simply

❯ nix build -f test/with-nixpkgs-ghc/default.nix
trace: No index state specified for haskell-project, using the latest index state that we know about (2023-02-01T00:00:00Z)!
error: attribute 'ghc8107xxx' missing

       at /home/andrea/work/haskell.nix/test/with-nixpkgs-ghc/default.nix:9:25:

            8|     let
            9|       haskell-nix-ghc = prev.haskell-nix.compiler.${compiler-nix-name};
             |                         ^
           10|       nixpkgs-ghc = prev.haskell.compiler.${compiler-nix-name};
(use '--show-trace' to show detailed location information)

but from an API pov your raise a good point because by referencing the compiler version by its name, haskell.nix has always replaced the compiler in nixpkgs. Perhaps we could (in some future) migrate to passing a compiler derivation attribute rather than compiler-nix-name?

@michaelpj
Copy link
Collaborator

Perhaps we could (in some future) migrate to passing a compiler derivation attribute rather than compiler-nix-name?

There's actually a reason why we do this... cross-compilation 🙈 We want to be able to select both the cross and normal version of the compiler, and the way we do this at the moment is by using the name as the key to look up both. An example of where this matters is when you have a cross-built project but you want to get a dev shell... then you need to use the non-cross compiler.

See #610 for when it was introduced.

but from an API pov your raise a good point because by referencing the compiler version by its name, haskell.nix has always replaced the compiler in nixpkgs.

A slightly more indirect way of supporting what you want here would be to provide a way to override haskell.nix's CompilerName -> Compiler mapping, so you would just pass { "ghc8107" = nixpkgs.ghc8107 } or something.

@andreabedini
Copy link
Member Author

Thanks for the explanation @michaelpj!

@hamishmack
Copy link
Collaborator

I'm closing this in favour of #1854 as I am borrowing the ideas here to use there.

@hamishmack hamishmack closed this Mar 3, 2023
@andreabedini andreabedini deleted the with-nixpkgs-ghc branch June 7, 2023 09:33
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 this pull request may close these issues.

5 participants