NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
18.38k stars 14.34k forks source link

`ghcjs.ghcWithPackages` fails with "error: value is a path while a set was expected" for certain packages #158600

Closed rzetterberg closed 2 years ago

rzetterberg commented 2 years ago

Describe the bug

When I run:

nix-shell -p 'pkgs.haskell.packages.ghcjs.ghcWithPackages (p: with p; [ reflex ])'

I get the following error:

error: value is a path while a set was expected

       at /nix/store/ivngb8kkjz9iy5ys433yf29xxn039ysl-nixos-21.11.335665.0f316e4d72d/nixos/pkgs/development/haskell-modules/lib/compose.nix:38:28:

           37|    */
           38|   overrideCabal = f: drv: (drv.override (args: args // {
             |                            ^
           39|     mkDerivation = drv: (args.mkDerivation drv).override f;
(use '--show-trace' to show detailed location information)

This problem does not happen if I run:

nix-shell -p 'pkgs.haskell.packages.ghcjs.ghcWithPackages (p: with p; [ base ])'

then the compilation starts, like expected. Same thing if I provide an empty list of packages.

Notify maintainers

Maintainers from haskell team: @cdepillabout, @expipiplus1, @maralorn, @sternenseemann

Metadata

Please run nix-shell -p nix-info --run "nix-info -m" and paste the result.

$ nix-shell -p nix-info --run "nix-info -m"
 - system: `"x86_64-linux"`
 - host os: `Linux 5.10.93, NixOS, 21.11 (Porcupine)`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.5.0pre20211206_d1aaa7e`
 - channels(zed): `""`
 - channels(root): `"nixos-21.11.335665.0f316e4d72d"`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`
sternenseemann commented 2 years ago

I believe withPackages is just not supported for ghcjs at all, base is a pseudo package and will just be reuse the bundled one. Have you been able to use any package that is not bundled with GHC?

cc @dfordivam

rzetterberg commented 2 years ago

I wasn't sure which packages were bundled, so I tried 16 packages (one by one) from one of my projects. Here are the results:

cdepillabout commented 2 years ago

cc @dfordivam

dfordivam commented 2 years ago

@rzetterberg I tried this with latest nixpkgs and did not observe this issue. But I did observe another problem, the ghcjs is not available in the shell created by ghcWithPackages. I also gave haskell.packages.ghcjs.developPackage a try on a cabal package using reflex-dom. That worked when withHoogle is set to false. I could get the shell with ghcjs and the cabal build succedded.

nix-shell -E 'with import ~/latest-nixpkgs { }; haskell.packages.ghcjs.developPackage { root = ./.; withHoogle = false;}'

rzetterberg commented 2 years ago

Thanks for the reply, @dfordivam

I haven't really been up to speed with the haskell ecosystem in nixpkgs, so I didn't even know about developPackage. I've used pkgs.haskellPackages.ghcWithPackages since like 2016 :stuck_out_tongue_closed_eyes:

So, If I understand it correctly, I could take something like this:

haskell_env = pkgs.haskell.packages.ghcjs.ghcWithPackages (p: with p; [
  base cabal-install reflex reflex-dom 
]);

And instead use something like this:

haskell_env = pkgs.haskell.packages.ghcjs.developPackage {
  root       = ./.;
  withHoogle = false;
  modifier   = drv:
    pkgs.haskell.lib.addBuildTools drv (with pkgs.haskellPackages; [
      base cabal-install reflex reflex-dom
    ]);
};

And that should give me the ability to build a project with ghcjs that uses the reflex and reflex-dom packages using cabal build?

rzetterberg commented 2 years ago

Here's the result for me when I tried the example you provided @dfordivam

nix-shell -E 'with import <nixpkgs> { }; haskell.packages.ghcjs.developPackage { root = ./.; withHoogle = false;}'
error: value is a path while a set was expected

       at /nix/store/ivngb8kkjz9iy5ys433yf29xxn039ysl-nixos-21.11.335665.0f316e4d72d/nixos/pkgs/development/haskell-modules/lib/compose.nix:38:28:

           37|    */
           38|   overrideCabal = f: drv: (drv.override (args: args // {
             |                            ^
           39|     mkDerivation = drv: (args.mkDerivation drv).override f;
(use '--show-trace' to show detailed location information)
sternenseemann commented 2 years ago

This seems to be fixed by a964dcad739fe70ed5e01646594aafdfb2be4560, for the evaluation part, as now a withPackages environment with all packages mentioned in your comment can be instantiated.

The remaining problem is that, well, ghcjs can't be built at the moment (#166553).

sternenseemann commented 2 years ago

I've tried building a few environments with ghcjs and everything seems to be working as expected. Note that none of the examples you have given in your comment can be expected to work, however, as they all depend on text-short which doesn't support GHCJS at the moment: https://github.com/haskell-hvr/text-short/issues/5

rzetterberg commented 2 years ago

Thank you, @sternenseemann! :1st_place_medal: