[Nix-dev] Pass cabal2nix's executableHaskellDepends to nix-shell environment for an executable-only project

Dmitry Malikov malikov.d.y at gmail.com
Sun Apr 10 16:30:53 CEST 2016


Assume there is a cabal project contains only of an executable:
Executable l
  Main-is:              Main.hs
  Default-Language:     Haskell2010
  HS-Source-Dirs:       src
  Ghc-Options:          -Wall
  Build-Depends:        base >= 4 && < 5
                      , p

Here is a l.nix produced by `cabal2nix .':
{ mkDerivation, base, p, stdenv }:
mkDerivation {
  pname = "l";
  isLibrary = false;
  isExecutable = true;
  executableHaskellDepends = [ base p ];
}

`default.nix':
{ nixpkgs ? import <nixpkgs> {}, compiler ? "ghc7103" }:
nixpkgs.pkgs.haskell.packages.${compiler}.callPackage ./l.nix { }

And finally `shell-nix':
{ nixpkgs ? import <nixpkgs> {}, compiler ? "ghc7103" }: let
  inherit (nixpkgs) pkgs;
  ghc = pkgs.haskell.packages.${compiler}.ghcWithPackages( ps: with ps; [
    cabal2nix hasktags stylish-haskell
  ]);
  hdevtools = pkgs.haskell.packages.${compiler}.callPackage ./hdevtools.nix
{ };
  cabal-install = pkgs.haskell.packages.${compiler}.cabal-install;
  pkg = (import ./default.nix { inherit nixpkgs compiler; });
in
  pkgs.stdenv.mkDerivation rec {
    name = pkg.pname;
    buildInputs = [ ghc cabal-install hdevtools ] ++ pkg.env.buildInputs;
    shellHook = ''
      ${pkg.env.shellHook}
      export IN_WHICH_NIX_SHELL=${name}
      cabal configure --enable-tests
--package-db=$NIX_GHC_LIBDIR/package.conf.d
    '';
  }

Unfortunately, `cabal configure' doesn't see `p' package:
cabal: At least the following dependencies are missing:
p -any

So the question is, how to add `executableHaskellDepends' to the
`buildInputs' list?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.science.uu.nl/pipermail/nix-dev/attachments/20160410/64823640/attachment.html 


More information about the nix-dev mailing list