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

nix-build haskell callPackage results in ghc: can't find a package database at #62906

Closed
chrissound opened this issue Jun 9, 2019 · 5 comments

Comments

@chrissound
Copy link

Issue description

nix build completed successfully earlier today, I don't think I made any changes, however when I now try to build:

nix build
builder for '/nix/store/jqdf06504qkqxchgy1v3dl4r4yk3gq4c-my-xmonad-0.2.0.0.drv' failed with exit code 1; last 10 log lines:
  setupCompilerEnvironmentPhase
  Build with /nix/store/d4c9yp4w96g45fivnljg32zjrvdfp10h-ghc-8.6.4.
  unpacking sources
  unpacking source archive /nix/store/1ry562ycdxbins0c9aqdsn7lk3ags1d4-MyXmonad
  source root is MyXmonad
  patching sources
  compileBuildDriverPhase
  setupCompileFlags: -package-db=/build/setup-package.conf.d -j4 -threaded
  Loaded package environment from /build/MyXmonad/.ghc.environment.x86_64-linux-8.6.4
  ghc: can't find a package database at /home/chris/.cabal/store/ghc-8.6.4/package.db
[0 built (1 failed), 0.0 MiB DL]
error: build of '/nix/store/jqdf06504qkqxchgy1v3dl4r4yk3gq4c-my-xmonad-0.2.0.0.drv' failed

And that directory:

ll /home/chris/.cabal/store/ghc-8.6.4/package.db
.rw-r--r--  20k chris  9 Jun 16:04 package.cache
.rw-r--r-- 2.4k chris  9 Jun 16:04 base-orphans-0.8.1-d1d5c2f906d8b31189d967f92e3dab8d190a4551016acb01a8f15fe2cc62b631.conf
.rw-r--r-- 1.5k chris  9 Jun 16:04 call-stack-0.1.0-b2e616096efae533904fd282961603c2a650c4d2c0c6d04175ef2ec29243a1fe.conf
.rw-r--r-- 2.0k chris  9 Jun 16:04 colour-2.3.4-9fb7aba525a78e0132d037e046484b52a23ce1e3e46720a9266c985bde608134.conf
.rw-r--r-- 1.5k chris  9 Jun 16:04 data-default-class-0.1.2.0-e2fae1c8a626f35fb46dd7274333d0deb7c563f41c08b45f363122b77dc260dc.conf
.rw-r--r-- 1.7k chris  9 Jun 16:04 extensible-exceptions-0.1.1.4-842e402c16ee90dcd51df6b94f6a971bc12ee71217b9d9ca62dc72dee04f97ea.conf
.rw-r--r-- 1.5k chris  9 Jun 16:04 old-locale-1.0.0.7-42d3c095826be03d22af56b0ee21c3cc822397c215396c1943b9567f2f9a6c65.conf
.rw-r--r--    0 chris  2 Jun 22:53 package.cache.lock

Technical details

nix-shell -p nix-info --run "nix-info -m" 
 - system: `"x86_64-linux"`
 - host os: `Linux 5.1.7, NixOS, 19.03.172837.6c3826d1c93 (Koi)`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.2.2`
 - channels(root): `"nixos-19.03.172837.6c3826d1c93, unstable-19.09pre181045.61f0936d1cd"`
 - channels(chris): `"nixos-18.09.1898.001b34abcb4, unstable-19.03pre166316.15eb4c361c7"`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`


Nix files were generated with cabal2nix

default.nix

{ nixpkgs ? import <nixpkgs> {}, compiler ? "ghc864" }:
nixpkgs.pkgs.haskell.packages.${compiler}.callPackage ./xmonad.nix { }

xmonad.nix

{ mkDerivation, base, containers, deepseq, hpack, lens, mtl
, pretty-simple, process, stdenv, string-conversions, time, X11
, xmonad, xmonad-contrib
}:
mkDerivation {
  pname = "my-xmonad";
  version = "0.2.0.0";
  src = ./.;
  isLibrary = false;
  isExecutable = true;
  libraryToolDepends = [ hpack ];
  executableHaskellDepends = [
    base containers deepseq lens mtl pretty-simple process
    string-conversions time X11 xmonad xmonad-contrib
  ];
  preConfigure = "hpack";
  license = stdenv.lib.licenses.gpl2;
}
@chrissound
Copy link
Author

Found a solution here: https://romanofskiat.wordpress.com/2019/02/07/ghc-cant-find-a-package-database/

rm .ghc.environment.*

@chrissound
Copy link
Author

Related issue: haskell/cabal#4542

@schonfinkel
Copy link
Member

schonfinkel commented Aug 18, 2019

Found a solution here: https://romanofskiat.wordpress.com/2019/02/07/ghc-cant-find-a-package-database/

rm .ghc.environment.*

Thanks for posting this! I had the same issue when using callCaba2nix in a previously working project and this also solved it for me.

@schonfinkel
Copy link
Member

For those who use both cabal and nix while developing, a possible nix-based solution is to not pass the .ghc-environment-* to the nix-build by using nix-gitignore:

{ pkgs ? import ./pinned-nixpkgs.nix {} }:
let
  gitignore = pkgs.nix-gitignore.gitignoreSource [] ./.;
in
pkgs.haskellPackages.callCabal2nix "PROJECT_NAME" gitignore {}

above a possible use within a default.nix.

@chrissound
Copy link
Author

Thanks for the fix @mtrsk I just realized I can fix another nix issue I've been having with that gitignoreSource!

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

2 participants