[Nix-dev] Haskell dependencies in a project
Brian McKenna
brian at brianmckenna.org
Sun Apr 3 07:35:06 CEST 2016
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
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
>
More information about the nix-dev
mailing list