[Nix-dev] Haskell dependencies in a project
Tomasz Czyż
tomasz.czyz at gmail.com
Sun Apr 3 17:08:02 CEST 2016
Brian, thank you for your response.
2016-04-03 5:35 GMT+00:00 Brian McKenna <brian at brianmckenna.org>:
> You need to call pkgs.haskellPackages.callPackage on my-dep, so it
> will look something like:
>
> dependencies = with pkgs.haskellPackages; [
> aeson (callpackage my-dep { })
> ];
>
> It's also possible to use the 'override' attribute instead, which
> would be useful if you later add a dependency which uses my-dep:
>
>
> https://nixos.org/nixpkgs/manual/#how-to-build-projects-that-depend-on-each-other
Do you know why I need to call callPackage? (I read in the manual from link
you provided that there is some package registration/discovery mechanism,
do you know if there is any explanation how that works?)
I have one problem with callPackage, it looks for a file "default.nix" in
directory "my-dep", but I wanted to declare that dependency locally (in the
same file as shown in example) - is it possible to use that kind of
dependency? (it works for me when I use python project for example).
>
>
> On 3 April 2016 at 12:15, Tomasz Czyż <tomasz.czyz at gmail.com> wrote:
> > Hi,
> >
> > I'm trying to make a nix/haskell package (with executable) with some
> > dependencies (from nixpkgs and some locally declared).
> >
> > I have my-dep directory with haskell package exposing library and src
> > directory which contains application using my-dep dependency and aeson
> > package from nixpkgs.
> >
> > Here is my nix expression:
> >
> > { pkgs ? import <nixpkgs> {} }:
> > let
> > my-dep = pkgs.haskellPackages.mkDerivation {
> > pname = "my-dep";
> > version = "0.1.0.0";
> > src = ./my-dep;
> > isLibrary=true;
> > isExecutable=false;
> > license = with pkgs; stdenv.lib.licenses.unfree;
> > doHaddock=false;
> > };
> > dependencies = with pkgs.haskellPackages; [
> > aeson my-dep
> > ];
> > ghc = pkgs.haskellPackages.ghcWithPackages(hs:(dependencies));
> > in
> > pkgs.haskellPackages.mkDerivation {
> > pname = "haskell-project";
> > version = "0.1.0.0";
> > src = ./src;
> > isLibrary = false;
> > isExecutable = true;
> > buildTools = [ghc];
> > buildDepends = dependencies;
> > license = with pkgs; stdenv.lib.licenses.unfree;
> > }
> >
> > (library expose 1 function which print text and main project just imports
> > aeson and my-dep and uses function from library)
> >
> > When building it, I am getting error:
> >
> > --------------------------------
> > Building haskell-project-0.1.0.0...
> > Preprocessing executable 'haskell-project' for haskell-project-0.1.0.0...
> >
> > Main.hs:2:18:
> > Could not find module ‘MyDep’
> > Use -v to see a list of the files searched for.
> > builder for
> > ‘/nix/store/43lbwp4qfigjwkf97nqp4h21hsrf5yr2-haskell-project-0.1.0.0.drv’
> > failed with exit code 1
> > error: build of
> > ‘/nix/store/43lbwp4qfigjwkf97nqp4h21hsrf5yr2-haskell-project-0.1.0.0.drv’
> > failed
> > ------------------------------------
> >
> > There is no problem with aeson (it's complaining about aeson when I
> remove
> > dependency from nix expression), but there is a problem with my-dep
> > dependency.
> >
> > Question is, how I should declare dependency for my-dep to make it
> working,
> > to make haskell-project to use that dependency correctly?
> >
> > (if I run nix-shell with this expression I have the same error, but if I
> > "cd" to my-dep directory and run ghc ../src/Main.hs it's working, it
> looks
> > like ghs tries search for MyDep.hs only in current directory instead of
> > package directory).
> >
> > _______________________________________________
> > nix-dev mailing list
> > nix-dev at lists.science.uu.nl
> > http://lists.science.uu.nl/mailman/listinfo/nix-dev
> >
>
--
Tomasz Czyż
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.science.uu.nl/pipermail/nix-dev/attachments/20160403/0462734f/attachment.html
More information about the nix-dev
mailing list