NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
18.19k stars 14.19k forks source link

nix-shell -p haskellPackages.ghcup fails #212716

Open CGenie opened 1 year ago

CGenie commented 1 year ago

Steps To Reproduce

Steps to reproduce the behavior:

  1. Run nix-shell -p haskellPackages.ghcup

Build log

At the end of the build I'm getting:

==============================
DOCTEST
==============================
src/lib/Haskus/Utils/Variant.hs:669: failure in expression `fromVariant @Double x'
expected: 
          ... error:
          ... `Double' is not a member of '[Int, String, Int]
          ...
 but got: 
          <interactive>:1133:1: error:
              • Double not found in list:
            ^
                 '[Int, String, Int]
              • In the expression: fromVariant @Double x
                In an equation for ‘it’: it = fromVariant @Double x

          <interactive>:1133:1: error:
              • `Double' is not a member of '[Int, String, Int]
              • In the expression: fromVariant @Double x
                In an equation for ‘it’: it = fromVariant @Double x

          <interactive>:1133:1: error:
              • Double not found in list:
                 '[Int, String, Int]
              • In the expression: fromVariant @Double x
                In an equation for ‘it’: it = fromVariant @Double x

Examples: 228  Tried: 228  Errors: 0  Failures: 1

==============================
SUMMARY
==============================
Test suite tests: FAIL
Test suite logged to: dist/test/haskus-utils-variant-3.3-tests.log
0 of 1 test suites (0 of 1 test cases) passed.
error: builder for '/nix/store/dxfb7skp8jvfhwjha66csvif4gampl23-haskus-utils-variant-3.3.drv' failed with exit code 1
error: 1 dependencies of derivation '/nix/store/3i2gix6gy4cbc0c4adj04lnvbqynvdvv-ghcup-0.1.18.0.drv' failed to build

Metadata

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

[user@system:~]$ nix-shell -p nix-info --run "nix-info -m"
this path will be fetched (0.00 MiB download, 0.00 MiB unpacked):
  /nix/store/pf0xc9gryi9dyp4c6zmynnp3blc547z9-nix-info
copying path '/nix/store/pf0xc9gryi9dyp4c6zmynnp3blc547z9-nix-info' from 'https://cache.nixos.org'...
 - system: `"x86_64-linux"`
 - host os: `Linux 5.15.0-56-generic, Ubuntu, 22.10 (Kinetic Kudu), nobuild`
 - multi-user?: `no`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.12.0`
 - channels(przemek): `"nixpkgs"`
 - nixpkgs: `/home/przemek/.nix-defexpr/channels/nixpkgs`
danielmain commented 1 year ago

Same Issue on aarch64-darwin

All 44 tests passed (0.00s)

src/lib/Haskus/Utils/Variant.hs:669: failure in expression `fromVariant @Double x'
expected: 
          ... error:
          ... `Double' is not a member of '[Int, String, Int]
          ...
 but got: 
          <interactive>:1133:1: error:
              • Double not found in list:
            ^
                 '[Int, String, Int]
              • In the expression: fromVariant @Double x
                In an equation for ‘it’: it = fromVariant @Double x

          <interactive>:1133:1: error:
              • `Double' is not a member of '[Int, String, Int]
              • In the expression: fromVariant @Double x
                In an equation for ‘it’: it = fromVariant @Double x

          <interactive>:1133:1: error:
              • Double not found in list:
                 '[Int, String, Int]
              • In the expression: fromVariant @Double x
                In an equation for ‘it’: it = fromVariant @Double x

Examples: 228  Tried: 228  Errors: 0  Failures: 1
nix-shell -p nix-info --run "nix-info -m"
 - system: `"aarch64-darwin"`
 - host os: `Darwin 22.3.0, macOS 13.2`
 - multi-user?: `yes`
 - sandbox: `no`
 - version: `nix-env (Nix) 2.13.2`
 - channels(daniel): `"darwin, home-manager, nixpkgs"`
 - channels(root): `"nixpkgs"`
 - nixpkgs: `/Users/daniel/.nix-defexpr/channels/nixpkgs`
ptkato commented 1 year ago

Is this an upstream problem? I found no tickets opened in the upstream's issue tracker regarding this particular problem; relevant lines.

ldicarlo commented 1 year ago

Hey, following https://github.com/haskus/packages/commit/389931f876827216957dc7191523fd3c2f3bf35b, it should be good now. I am not used to the process of updating nixpkgs, but could we update to the last version?

ldicarlo commented 1 year ago

So I am still looking into this issue. Skipping the checks in a dependency of ghcup can be donne like this:

./flake.nix
# run using `NIXPKGS_ALLOW_BROKEN=1 nix develop --impure`
{
  inputs.nixpkgs.url = "github:nixos/nixpkgs";

  outputs = { self, nixpkgs, }:
    let
      system = "x86_64-linux";
      pkgs = import nixpkgs { inherit system; };

      myHaskellPackages = pkgs.haskellPackages.override {
        overrides = hself: hsuper: {
          haskus-utils-variant = pkgs.haskell.lib.dontCheck hsuper.haskus-utils-variant;
        };
      };
    in
    {
      devShells.${system}.default = pkgs.mkShell
        {
          nativeBuildInputs = with pkgs; [ ];
          buildInputs = with pkgs;
            [
              myHaskellPackages.ghcup
            ];
        };
    };
}

But then I find other problems of missing packages. Currently I have this version:

{
  inputs.nixpkgs.url = "github:nixos/nixpkgs";

  outputs = { self, nixpkgs, }:
    let
      system = "x86_64-linux";
      pkgs = import nixpkgs { inherit system; };

      myHaskellPackages = pkgs.haskellPackages.override {
        overrides = hself: hsuper: {
          haskus-utils-variant = pkgs.haskell.lib.dontCheck hsuper.haskus-utils-variant;
          retry = pkgs.haskell.lib.doJailbreak hsuper.retry;
          streamly = pkgs.haskell.lib.doJailbreak hsuper.streamly;
          template-haskell = pkgs.haskell.lib.doJailbreak hsuper.template-haskell_2_20_0_0;
          time = pkgs.haskell.lib.doJailbreak hsuper.time_1_12_2;
        };
      };
    in
    {
      devShells.${system}.default = pkgs.mkShell
        {
          nativeBuildInputs = with pkgs; [ ];

          buildInputs = with pkgs;
            [
              myHaskellPackages.ghcup
            ];
        };
    };
}

Which does not work:

error: builder for '/nix/store/jsm3f998bkbf85kkjyak9lq2braw88xk-template-haskell-2.20.0.0.drv' failed with exit code 1;
       last 10 log lines:
       > Language/Haskell/TH/Syntax.hs:830:18: error:
       >     Not in scope: data constructor ‘LangJs’
       >     Suggested fix:
       >       Perhaps use one of these:
       >         ‘LangC’ (imported from GHC.ForeignSrcLang.Type),
       >         ‘LangAsm’ (imported from GHC.ForeignSrcLang.Type)
p-alik commented 4 months ago

I run in the issue as well

$ NIXPKGS_ALLOW_BROKEN=1 nix-shell -p haskellPackages.ghcup
...
Warning: Text.Libyaml: could not find link destinations for: 
        - Text.Libyaml.formatOptionsRenderTags
        - Text.Libyaml.TagRender
error: builder for '/nix/store/0sa3ha03nz2w7v82slis5idpscgp86j6-haskus-utils-variant-3.4.drv' failed with exit code 1;
       last 10 log lines:
       > [1 of 3] Compiling EADT             ( src/tests/EADT.hs, dist/build/tests/tests-tmp/EADT.o )
       >
       > src/tests/EADT.hs:33:1: error: [GHC-15172]
       >     • Pattern synonyms do not support linear fields (GHC #18806):
       >         a %1 -> EADT xs %1 -> EADT xs
       >     • In the declaration for pattern synonym ‘Cons’
       >    |
       > 33 | eadtPattern 'ConsF "Cons"
       >    | ^^^^^^^^^^^^^^^^^^^^^^^^^
       > [2 of 3] Compiling Variant          ( src/tests/Variant.hs, dist/build/tests/tests-tmp/Variant.o )
       For full logs, run 'nix-store -l /nix/store/0sa3ha03nz2w7v82slis5idpscgp86j6-haskus-utils-variant-3.4.drv'.
error: 1 dependencies of derivation '/nix/store/zk42xbkzdd9f260zajxj6m42jhklb1b2-ghcup-0.1.22.0.drv' failed to build
$ nix-shell -p nix-info --run "nix-info -m"
 - system: `"x86_64-linux"`
 - host os: `Linux 6.6.33, NixOS, 24.05 (Uakari), 24.05.1409.cc54fb41d137`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.18.2`
 - channels(root): `"nixos-24.05"`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`
nixos-discourse commented 4 months ago

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/unable-to-use-haskell-for-visual-studio-code/47595/1

CapSel commented 4 months ago

While it's not a real solution to this problem you could use cabal2nix to use nix for installation of dependencies. There is a nice documentation about it here https://haskell4nix.readthedocs.io/nixpkgs-users-guide.html#how-to-create-nix-builds-for-your-own-private-haskell-packages

p-alik commented 4 months ago

Thank you @CapSel. What should be done to resolve this issue here? Seems the problem wasn't reported to upstream https://github.com/haskus/packages/issues

nixos-discourse commented 4 months ago

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/unable-to-use-haskell-for-visual-studio-code/47595/7

hsyl20 commented 3 months ago

I'm the developer of the haskus-utils-variant package used by ghcup.

Using the 3.5 release should fix your issues. Don't hesitate to open a ticket if there are other issues.

Piturnah commented 1 month ago

Can this be backported to 24.05?

EDIT: Actually, on unstable, I'm still not building with

error: Package ‘haskus-utils-variant-3.5’ in /nix/store/ckvn0n19hy6lxgf6ws6l6d436041b1wj-unstable/unstable/pkgs/development/haskell-modules/hackage-packages.nix:144254 is marked as broken, refusing to evaluate.
hsyl20 commented 1 month ago

I'm not sure why haskus-utils-variant-3.5 is marked broken.

Anyway the next release of ghcup should be much easier to distribute because it switches from haskus-utils-variant to variant (cf https://github.com/haskell/ghcup-hs/commit/31274cbeecfe373e8e54167975bb0e65f5b72587)

@hasufell is there a release planned soon?

hasufell commented 1 month ago

@hasufell is there a release planned soon?

I can make a hackage-only release for that I guess?

hasufell commented 1 month ago

It looks like @maralorn dropped it anyway? https://github.com/NixOS/nixpkgs/commit/a7d50b4e0988e4f53d2d3629c7b5f57c2736480f#diff-06cdf278a2cf7f0e7793a4a8d19cbdd6e6a3a3722482708833ef9270b65d7d56

maralorn commented 1 month ago

Wow, gotta love those issues which go 1.5 years without anyone tagging the Haskell team.

I once maintained ghcup within nixpkgs, which probably wouldn't be hard to do again. However, as far am I aware ghcup does not offer to install a ghc which works on nixos. So I decided there is no point in maintaining it.

hasufell commented 1 month ago

However, as far am I aware ghcup does not offer to install a ghc which works on nixos.

Recent GHCs provide fully static bindists, but there was an issue with those bindists, but I forgot what it was... it fell over with cabal (I don't remember if it was during static or dynamic linking).

https://downloads.haskell.org/~ghc/9.10.1/ghc-9.10.1-x86_64-alpine3_12-linux-static.tar.xz

maralorn commented 1 month ago

As soon as it is a viable option I am happy to fix and maintain ghcup. Having a unified experience, especially for beginners, is important.