[Nix-dev] Developing Haskell packages that use the FFI

Ian Duncan ian at iankduncan.com
Sat Mar 7 04:36:09 CET 2015


Hi there,

I’m pretty new to NixOS, and I’m trying to get into using it for Haskell development. So far, I’ve been following the guide here (http://wiki.ocharles.org.uk/Nix) with moderate success for libraries that don’t directly need to interact with C/C++ libraries. However, I’ve got some projects that I’m working on that use “picky” libraries (for lack of a better term).

To be specific, I’ve got two packages that I’m working on that are giving me grief:

I’m working on a package that depends on the hs-mesos cabal package, but I’m ending up with the wrong version of the C++ protobuf library (incompatible headers) due to Nix somehow automatically picking up the wrong protobuf dependency for using the mesos C++ headers. How can I configure what version of protobuf is used for mesos / hs-mesos?
My shell.nix is:

with (import <nixpkgs> {}).pkgs;
(haskellngPackages.callPackage ./. {}).env
And my default.nix is:

{ mkDerivation, base, hs-mesos, hzk, lens, stdenv, stm }:
mkDerivation {
  pname = "mesotron";
  version = "0.1.0.0";
  src = ./.;
  isLibrary = false;
  isExecutable = true;
  buildDepends = [ base hs-mesos hzk lens stm ];
  license = stdenv.lib.licenses.unfree;
}
Similarly, I’m trying to write Haskell bindings for libzfs, don’t know how to pull in the zfs dependency properly. This one seems to be more complex– I need to add something like ${zfs}/include/libspl & ${zfs}/include/libzfs to the include paths, but even after doing that, I get macro recursion errors in glib?
In file included from /nix/store/93zfs0zzndi7pkjkjxawlafdj8m90kg5-glibc-2.20/include/unistd.h:610:0:
    0,
                     from /nix/store/g6d4ddw286x57m5drm905fhnqac68i8q-zfs-user-0.6.3-1.2/include/libspl/unistd.h:28,
                     from /nix/store/g6d4ddw286x57m5drm905fhnqac68i8q-zfs-user-0.6.3-1.2/include/libspl/sys/param.h:32,
                     from /nix/store/g6d4ddw286x57m5drm905fhnqac68i8q-zfs-user-0.6.3-1.2/include/libspl/sys/types.h:34,
                     from /nix/store/93zfs0zzndi7pkjkjxawlafdj8m90kg5-glibc-2.20/include/stdlib.h:315,
                     from /nix/store/g6d4ddw286x57m5drm905fhnqac68i8q-zfs-user-0.6.3-1.2/include/libspl/stdlib.h:28,
                     from /nix/store/g6d4ddw286x57m5drm905fhnqac68i8q-zfs-user-0.6.3-1.2/include/libspl/assert.h:34,
                     from /nix/store/g6d4ddw286x57m5drm905fhnqac68i8q-zfs-user-0.6.3-1.2/include/libzfs/libzfs.h:34,
                     from src/ZFS.hs:4:

/nix/store/93zfs0zzndi7pkjkjxawlafdj8m90kg5-glibc-2.20/include/bits/confname.h:201:0:
     error: detected recursion whilst expanding macro "_SC_UIO_MAXIOV"
         _SC_IOV_MAX = _SC_UIO_MAXIOV,
     ^

/nix/store/93zfs0zzndi7pkjkjxawlafdj8m90kg5-glibc-2.20/include/bits/confname.h:497:0:
     error: detected recursion whilst expanding macro "_SC_LEVEL1_ICACHE_SIZE"
         _SC_IPV6 = _SC_LEVEL1_ICACHE_SIZE + 50,
     ^

In file included from /nix/store/g6d4ddw286x57m5drm905fhnqac68i8q-zfs-user-0.6.3-1.2/include/libzfs/libzfs.h:34:0:
    0,
                     from src/ZFS.hs:4:

/nix/store/g6d4ddw286x57m5drm905fhnqac68i8q-zfs-user-0.6.3-1.2/include/libspl/assert.h:39:0:
     error: detected recursion whilst expanding macro "stderr"
      fprintf(stderr, "%s:%i: %s: Assertion `%s` failed.\n",
     ^
Anyways, these questions are kind of ill-formed, for which I apologize. I’m not really sure what I’m missing here, and I just don’t have enough experience with Nix yet to understand what I’m doing wrong.



– Ian Duncan

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.science.uu.nl/pipermail/nix-dev/attachments/20150306/519da77b/attachment-0001.html 


More information about the nix-dev mailing list