Nixpkgs: overriding cabal in ghc

Created on 30 Aug 2019  路  14Comments  路  Source: NixOS/nixpkgs

commit 2e08ac73ca0098bf6dead801631c909d3a6b8e85
changed ghc 8.6.5 to use cabal 3.
I wonder if there is way to revert that to cabal 2 via an override/overlay ?
haskell-ide-engine seems to have some problems with cabal 3.

I've tried changing the line in pkgs/development/haskell-modules/configuration-ghc-8.6.x.nix to
cabal-install = super.cabal-install.overrideScope (self: super: { Cabal = self.Cabal_2_4_1_0; });
but it triggers:

building '/nix/store/b945pczx14d1dbx97lb0i0rzfkpz2p6q-cabal-install-3.0.0.0.drv'...
setupCompilerEnvironmentPhase
Build with /nix/store/42ikjm2msdg8awxvlljr0h4lkldibdbb-ghc-8.6.5.
unpacking sources
unpacking source archive /nix/store/i7gd80q1dlf01hrlsdv5z9ngdajrzp8n-cabal-install-3.0.0.0.tar.gz
source root is cabal-install-3.0.0.0
setting SOURCE_DATE_EPOCH to timestamp 1000000000 of file cabal-install-3.0.0.0/tests/README.md
patching sources
compileBuildDriverPhase
setupCompileFlags: -package-db=/build/setup-package.conf.d -j4 -threaded
[1 of 1] Compiling Main             ( Setup.hs, /build/Main.o )
Linking Setup ...
configuring
configureFlags: --verbose --prefix=/nix/store/wq96d1iza4hawk1rzx153z285q304x6i-cabal-install-3.0.0.0 --libdir=$prefix/lib/$compiler --libsubdir=$abi/$libname --docdir=/nix/store/07dd0ajlnawhia9vwm01mryx5a0799dz-cabal-install-3.0.0.0-doc/share/doc/cabal-install-3.0.0.0 --with-gcc=gcc --package-db=/build/package.conf.d --ghc-option=-j4 --disable-split-objs --enable-library-profiling --profiling-detail=exported-functions --disable-profiling --enable-shared --disable-coverage --enable-static --disable-executable-dynamic --disable-tests --disable-benchmarks --enable-library-vanilla --disable-library-for-ghci --ghc-option=-split-sections --extra-lib-dirs=/nix/store/vwcrxiwxr294b7iargxcqbda0nr89vfn-ncurses-6.1-20190112/lib --extra-lib-dirs=/nix/store/8pivgdaciz2add2wv7ff13gbz0rijs3f-libffi-3.2.1/lib --extra-lib-dirs=/nix/store/yq9lngyw980m5xdavkzb275xp50nx4my-gmp-6.1.2/lib
Using Parsec parser
Configuring cabal-install-3.0.0.0...
CallStack (from HasCallStack):
  die', called at ./Distribution/Simple/Configure.hs:952:20 in Cabal-2.4.1.0-9MZFDeNrcJI10bcroa6pq8:Distribution.Simple.Configure
  configureFinalizedPackage, called at ./Distribution/Simple/Configure.hs:462:12 in Cabal-2.4.1.0-9MZFDeNrcJI10bcroa6pq8:Distribution.Simple.Configure
  configure, called at ./Distribution/Simple.hs:596:20 in Cabal-2.4.1.0-9MZFDeNrcJI10bcroa6pq8:Distribution.Simple
  confHook, called at ./Distribution/Simple/UserHooks.hs:67:5 in Cabal-2.4.1.0-9MZFDeNrcJI10bcroa6pq8:Distribution.Simple.UserHooks
  configureAction, called at ./Distribution/Simple.hs:178:19 in Cabal-2.4.1.0-9MZFDeNrcJI10bcroa6pq8:Distribution.Simple
  defaultMainHelper, called at ./Distribution/Simple.hs:124:42 in Cabal-2.4.1.0-9MZFDeNrcJI10bcroa6pq8:Distribution.Simple
  defaultMainWithHooks, called at Setup.hs:42:8 in main:Main
Setup: Encountered missing dependencies:
Cabal ==3.0.*

note: keeping build directory '/tmp/nix-build-cabal-install-3.0.0.0.drv-1'
builder for '/nix/store/b945pczx14d1dbx97lb0i0rzfkpz2p6q-cabal-install-3.0.0.0.drv' failed with exit code 1
error: build of '/nix/store/b945pczx14d1dbx97lb0i0rzfkpz2p6q-cabal-install-3.0.0.0.drv' failed

A similar error happens if I remove the line instead of modifying it.

cc @peti

question haskell

All 14 comments

commit 2e08ac7 changed ghc 8.6.5 to use cabal 3

That is not quite correct. The commit builds cabal-install with Cabal 3.x -- not ghc. The Cabal version shipped by ghc it completely unaffected by this change.

ok sry, clearly I don't get everything that's going on but is there a way to get cabal 2.4 when running a nix-shell with ghc 8.6.5 ? what should I modify

I am sorry, but the description of the problem you are trying to solve makes not much sense. I don't see how cabal-install could possible affect haskell-ide-engine. I am not even aware of such a package in Nixpkgs.

https://github.com/haskell/haskell-ide-engine (HIE) is an LSP server for haskell (which provides IDE features for text editors such as vim: it helps finding haskell code definition, formatting code, displaying doc etc)
HIE works great except it doesn't support cabal new-build. With cabal 3, one of the component (ghc-mod and cabal-helper, not sure) calls cabal configure instead of cabal v1-configure which messes up with the software.

I used to have ghc8.6.5 with cabal 2, now it's ghc8.6.5 with cabal 3. How can I revert to the previous situation ?

NB: It's not in nixpkgs yet due to issues with ghc-mod etc but https://github.com/Infinisil/all-hies works great

How can I revert to the previous situation ?

You can't, really. Nixpkgs makes no effort to support cabal-install 2.x now that 3.x is out.

What you can do is ...

  1. use an older version of Nixpkgs.
  2. use a release branch like release-19.03 which doesn't update to the latest version ASAP.
  3. bother upstream to fix their code in HIE to prefix all cabal-install commands with v1- to make sure they work properly with recent version of the tool.
  4. make an effort to add cabal-install 2.4.x to your local copy of Nixpkgs through an override.
    https://nixos.org/nixpkgs/manual/#how-to-create-nix-builds-for-your-own-private-haskell-packages has plenty of relevant documentation.

I hope this helps!

ok thanks

@peti I wouldn't mind maintaining a cabal-install < 3 in nixpkgs for now. I think it's reasonable to have such a version for a while since v3 has a bunch of backwards-incompatible changes and this is a very integral part of the Haskell ecosystem. If that's alright with you I'll push a commit for adding a cabal-install < 3 to extra-packages and will then check the build status later.

I wouldn't mind maintaining a cabal-install < 3 in nixpkgs for now.

I don't see much of a need for having cabal 2.4.x in Nixpkgs, to be honest. Instead of investing time into maintaining that obsolete tool, I'd much rather invest that time into fixing those programs that can't cope with the 3.x version.

Unfortunately, at least in case of HIE, that's a lot of work, and work I can't do fully myself. In comparison maintaining a cabal-install < 3 is something I'm very familiar with and will probably not require much more than a bunch of Nix lines.

Hi, yes, I can confirm that cabal 3 and the current HIE from @Infinisil's all-hies don't work together.

I'm trying to add cabal-install 2.4.1.0 to my overlays in configuration.nix, but I don't know how to do this for haskell packages.
So far I've got this pulled out out of a previous hackage-packages.nix file:

{ mkDerivation, array, async, base, base16-bytestring, binary
, bytestring, Cabal, containers, cryptohash-sha256, deepseq
, directory, echo, edit-distance, filepath, hackage-security
, hashable, HTTP, mtl, network, network-uri, parsec, pretty
, process, random, resolv, stdenv, stm, tar, text, time, unix, zip-archive
, zlib
}:
mkDerivation {
  pname = "cabal-install";
  version = "2.4.1.0";
  sha256 = "1b91rcs00wr5mf55c6xl8hrxmymlq72w71qm5r0q4j869asv5g39";
  revision = "3";
  editedCabalFile = "1mnm6mfrgavq3blvkm3wz45pqrj10apjihg1g9cds58qp19m9r1h";
  isLibrary = false;
  isExecutable = true;
  setupHaskellDepends = [ base Cabal filepath process ];
  executableHaskellDepends = [
    array async base base16-bytestring binary bytestring Cabal
    containers cryptohash-sha256 deepseq directory echo edit-distance
    filepath hackage-security hashable HTTP mtl network network-uri
    parsec pretty process random resolv stm tar text time unix
    zip-archive zlib
  ];
  doCheck = false;
  postInstall = ''
    mkdir $out/etc
    mv bash-completion $out/etc/bash_completion.d
  '';
  description = "The command-line interface for Cabal and Hackage";
  license = stdenv.lib.licenses.bsd3;
  maintainers = with stdenv.lib.maintainers; [ peti ];
}

How would I add this to the nixpkgs.overlays section in configuration.nix?

https://nixos.org/nixpkgs/manual/#how-to-create-nix-builds-for-your-own-private-haskell-packages

Unfortunately, at least in case of HIE, that's a lot of work, and work I can't do fully myself. In comparison maintaining a cabal-install < 3 is something I'm very familiar with and will probably not require much more than a bunch of Nix lines.

How about adding that old cabal-install version into your overlay next to HIE?

as everyone I am very annoyed that hie doesn't work with cabal 3 but I don't think nixos-unstable should go out of its way to solve this.
I don't think we will see HIE support new builds before a few months.
If we don't modify nixpkgs, solutions are:

  • pinning nixpkgs for haskell modules (which I do)
  • explain how to make hie work with nixos-unstable in an overlay (how is that even possible since cbal is bundled with ghc : would changing cabal-install be enough ? just revert ghc865 changes ?)
  • wait for a quickfix to hie. They would be picked up by all-hies ?!

@peti thanks, that link led me eventually to a working cabal 2.4.1.0 overlay, especially section 9.6.3.2.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ghost picture ghost  路  3Comments

edolstra picture edolstra  路  3Comments

ayyess picture ayyess  路  3Comments

chris-martin picture chris-martin  路  3Comments

tomberek picture tomberek  路  3Comments