If I build my Haskell project under nix-shell
it gives error about missing zlib
.
If I build the project in nix-shell using nix-shell -p zlib
then the project sees zlib
and builds successfully.
How can I add the zlib
package to shell.nix
file so that passing -p zlib
is no longer needed?
Note: the builds were done using cabal v2-build
For building with stack I had to do the following
This is how my shell.nix
is currently defined:
{ nixpkgs ? import <nixpkgs> {}, compiler ? "default", doBenchmark ? false }:
let
inherit (nixpkgs) pkgs;
f = { mkDerivation, base, directory, stdenv, text, turtle, zlib }:
mkDerivation {
pname = "haskell-editor-setup";
version = "0.1.0.0";
src = ./.;
isLibrary = false;
isExecutable = true;
executableHaskellDepends = [ base directory text turtle zlib ];
description = "Terminal program that will set up Haskell environment with a target selected editor or IDE";
license = stdenv.lib.licenses.gpl3;
};
haskellPackages = if compiler == "default"
then pkgs.haskellPackages
else pkgs.haskell.packages.${compiler};
variant = if doBenchmark then pkgs.haskell.lib.doBenchmark else pkgs.lib.id;
drv = variant (haskellPackages.callPackage f {});
in
if pkgs.lib.inNixShell then drv.env else drv
I got it to work by creating a GHC environment using a haskell+nix tutorial. Below is my release.nix
and default.nix
is generated via cabal2nix . > default.nix
: (note the zlib
as a part of the haskell packages to include in the ghcWithPackages
call)
let
config =
{
packageOverrides = pkgs:
{
haskellPackages = pkgs.haskellPackages.override
{
overrides = new: old:
{
interview = new.callPackage ./default.nix;
};
};
};
};
pkgs = import <nixpkgs> { inherit config; };
ghc = pkgs.haskellPackages.ghcWithPackages (hpkgs: with hpkgs;
[ cabal-install
interview
zlib
]
);
in
with pkgs;
mkShell
{ buildInputs = [ ghc ];
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With