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

Can't build cabal from sources. #545

Closed
typetetris opened this issue Apr 13, 2020 · 3 comments
Closed

Can't build cabal from sources. #545

typetetris opened this issue Apr 13, 2020 · 3 comments

Comments

@typetetris
Copy link
Contributor

Steps to reproduce

  1. git clone https://github.com/haskell/cabal.git
  2. cd cabal
  3. git branch v32 cabal-install-v3.2.0.0
  4. git checkout v32
  5. create default.nix with the folloging content
let 
  # Fetch the latest haskell.nix and import its default.nix 
  haskellNix = import (builtins.fetchTarball https://github.com/input-output-hk/haskell.nix/archive/master.tar.gz) {};
  # haskell.nix provides access to the nixpkgs pins which are used by our CI, hence
  # you will be more likely to get cache hits when using these. 
  # But you can also just use your own, e.g. '<nixpkgs>'
  nixpkgsSrc = haskellNix.sources.nixpkgs-1909;
  # haskell.nix provides some arguments to be passed to nixpkgs, including some patches
  # and also the haskell.nix functionality itself as an overlay.
  nixpkgsArgs = haskellNix.nixpkgsArgs;
in
{ pkgs ? import nixpkgsSrc nixpkgsArgs
, haskellCompiler ? "ghc865"
}:
# 'cabalProject' generates a package set based on a cabal.project (and the corresponding .cabal files)
pkgs.haskell-nix.cabalProject {
  # 'cleanGit' cleans a source directory based on the files known by git
  src = pkgs.haskell-nix.haskellLib.cleanGit { src = ./.; };
  ghc = pkgs.buildPackages.pkgs.haskell-nix.compiler.${haskellCompiler};
}
  1. nix build -f default.nix cabal-install.components.exes.cabal
  2. See it fail.

Additional Info

Trying to look around in the resulting derivation with

 nix repl default.nix

and using tab completion, shows, there is a Cabal key, but it has a null value.

Also entering the shell with

nix-shell -A shellFor default.nix

and using

ghc-pkg list

shows, that the only Cabal the library package known to the compiler in the shell is the one
it brings with it. (At the time of writing: Cabal-2.4.0.1)

@hamishmack
Copy link
Collaborator

Try:

pkgs.haskell-nix.cabalProject {
  # 'cleanGit' cleans a source directory based on the files known by git
  src = pkgs.haskell-nix.haskellLib.cleanGit { src = ./.; };
  ghc = pkgs.buildPackages.pkgs.haskell-nix.compiler.${haskellCompiler};
  modules = [ { reinstallableLibGhc = true; } ];
}

The reinstallableLibGhc = true will tell cabalProject that it is ok not to use the Cabal that came with ghc and instead install a new one if necessary (in this case it should install the one from the project itself).

@KiaraGrouwstra
Copy link

KiaraGrouwstra commented Jun 25, 2020

Did this solution work for you @typetetris? I've been having trouble with it.

edit: this went thru for me now. :)

@hamishmack
Copy link
Collaborator

reinstallableLibGhc is now the default

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

No branches or pull requests

3 participants