[Nix-dev] Exposing Haskell library + binary when using nix-shell and cabal build

Mateusz Kowalczyk fuuzetsu at fuuzetsu.co.uk
Sun Apr 27 23:49:42 CEST 2014


Hello,

I'm trying to work on Yi, the text editor written in Haskell.

Following [1] and with some help on this list, I managed to get
nix-shell working. As I understand it, I should be able to use it
instead of cabal sandboxes.

There is a problem with this approach that I don't know how to get
around. Yi produces a binary and a library: the binary then loads the
library at run-time.

With cabal sandboxes, I had a cabal package database per-sandbox and was
able to run Yi from within a sandbox while pointing it at that library.
My wrapper script from my previous setup is something like this:

export
GHC_PACKAGE_PATH=$HOME/programming/yi/yi/.cabal-sandbox/i386-linux-ghc-7.6.3-packages.conf.d:$GHC_PACKAGE_PATH
$HOME/programming/yi/yi/.cabal-sandbox/bin/yi "$@"

This worked fine and I could point other things there if I needed to and
they would see the libraries.

With nix-shell followed by ‘cabal build’, we do not get such a database.
Running Yi, we quickly find out that it can't find its own libraries.

OK, I think, I will try ‘cabal install’, it should get registered and be
able to see its own library. This approach doesn't work, ‘cabal install’
fails with:

yi-0.8.1: dependency "dlist-0.7.0.1-097643e4e208c620450bdd15d82b0b72"
doesn't
exist (use --force to override)
yi-0.8.1: dependency "dyre-0.8.12-ec18729a01bb7f4f276d764f16f59f88" doesn't
exist (use --force to override)
yi-0.8.1: dependency "fingertree-0.1.0.0-7b004cd58ca38ab98a8debc0170a04be"
doesn't exist (use --force to override)
yi-0.8.1: dependency "glib-0.12.5.4-407a95c1ac58268bb8de695128c633b1"
doesn't
exist (use --force to override)
…

and many more of these. As far as I can tell there's one for each
dependency.

‘cabal haddock’ fails as well:

Running Haddock for yi-0.8.1...
Preprocessing library yi-0.8.1...
<command line>: cannot satisfy -package-id
Diff-0.3.0-56d6d899a3d3165124001f1cd6bed1a7
    (use -v for more information)

but I will attempt to resolve that afterwards.

My questions are:

* How can I point Yi (and other programs) at the package database set up
by nix-shell?

* Am I ever meant to be running ‘cabal install’ from within nix-shell?

* If I am meant to use ‘cabal install’, will nix do The Right Thing™ or
will the binary escape to the global cabal bin store?

You can find the default.nix I'm using for Yi at [2].

As usual, thank you for any help.

[1]:
http://ocharles.org.uk/blog/posts/2014-02-04-how-i-develop-with-nixos.html
[2]: http://lpaste.net/103284

-- 
Mateusz K.


More information about the nix-dev mailing list