Closed peti closed 9 years ago
curlhs
requires libcurl
at runtime (version 7.20 or above). It compiles without libcurl
, but at runtime dlopen
is used to load libcurl.so.4
(or libcurl.so
), and if that fails, curlhs
throws an exception (like in the tests above).
Is libcurl
installed during tests?
We install whatever the cabal file lists as dependencies.
Is it possible to specify additional dependencies? Besides what's in cabal?
I see 'curl-7.42.1' package on the 'Build dependencies' list, but only as indirect dependency. I think it should be there directly below 'curlhs' and on the 'Runtime dependencies' list too (but I don't know much about nixos packaging, sorry).
Your Cabal file should specify an attribute extra-libraries: curl
in the test suite stanza. If you do that, NixOS will automatically include the curl library in the environment. Similarly, cabal-install
will check whether curl
is available when people configure the build with --enable-tests
.
extra-libraries: curl
may work for nix, but I cannot accept this in general. This solution puts a hard requirement on libcurl
(only for tests but still) and this is just not right. libcurl
is optional.
curlhs
compiles and runs without libcurl
in scope (it is useless then, but it works). Users may catch
exceptions and decide what to do when there is no libcurl
(or wrong version). Maybe I should do the same in curlhs
tests. Actually it was so already before (ee4c4867bbee59de5b53186264a88cd376bdbb42). I can bring it back, but this only hides the problem, I think.
One example (that I know of) which uses the similar technique (dlopen()
optional dependencies) is the SDL2_image
library (C library, not Haskell). Support for png, jpeg etc. is optional and depends on the availability of the suitable library. In the SDL2_image
's default.nix file there is a line:
buildInputs = [SDL2 libpng libjpeg libtiff libungif libXpm zlib];
Is something similar possible to do for Haskell packages? As I see, Haskell nix files are auto-generated from cabal files, but maybe there is some way to specify additional info on the nix level?
Put the extra-libraries
attribute into the test suite stanza.
Sorry, but this doesn't convince me. There must be another way.
I don't understand your concerns. People who configure --enable-tests
have a dependency on curl
. People who don't want to run the test suite, don't have a dependency on curl
. Where is the problem?
I don't want extra-libraries
in curlhs.cabal
because it is not really necessary to build te test suite and it is problematic on non-unix systems (yes, Windows and its problems with foreign libraries).
On the other side even people that don't run tests will want libcurl
in the environment. The libraries are independent, but it doesn't make sense to use curlhs
without libcurl
.
What about mikmod package? There is no extra-libraries
field in mikmod.cabal, however it depends on libmikmod
package (it's listed here). I've found something like this in configuration-common.nix:
# https://github.com/evanrinehart/mikmod/issues/1
mikmod = addExtraLibrary super.mikmod pkgs.libmikmod;
curl
is necessary to run the test suite because without it the test suite will fail! What's the point of building a test suite that cannot be run? Or rather, that's going to report a test suite failure when you try to run it? That's even worse than not being able to run it in the first place.
The manual override for miknod
is necessary only because our auto-generator isn't smart enough yet to deduce that a dependency on the miknod.h
header implies a dependency on the miknod
library. Once cabal2nix
knows that these two things are connected, the override can be (and will be) removed.
Maybe auto-generator will never be smart enough to cover all use cases. I'm going different path than others. It may be wrong. But who knows.
Well, it's free software and you can write and/or publish it any way you please.
Citing from http://hydra.cryp.to/build/875475/nixlog/3/raw: