Via Gabriel Gonzalez, see this issue for details.
Nix lets you create transient GHC environments with corresponding package databases that may be needed to run LH on specific programs.
- Create shell, that lists the extra dependencies:
- the version of GHC (must be the same as you build LH with, e.g. GHC 8.0.2)
- any extra libraries (e.g.
vector
)
$ nix-shell --packages 'haskell.packages.ghc802.ghcWithPackages (pkgs: [ pkgs.vector ])'
- Set environment variables
[nix-shell]$ eval "$(egrep ^export "$(type -p ghc)")"
- Run LH
[nix-shell]$ liquid examples/search.hs
Steps 1-3 can be encapsulated in a single shell.nix
e.g.
let
inherit (import <nixpkgs> { }) fetchFromGitHub;
nixpkgs = fetchFromGitHub {
owner = "NixOS";
repo = "nixpkgs";
rev = "1715436b75696d9885b345dd8159e12244d0f7f5";
sha256 = "18qp76cppm1yxmzdaak9kcllbypvv22c9g7iaycq2wz0qkka6rx5";
};
pkgs = import nixpkgs { };
liquid =
pkgs.runCommand "liquidhaskell" { buildInputs = [ pkgs.makeWrapper ]; } ''
mkdir -p $out/bin
ln -s ${pkgs.haskellPackages.liquidhaskell}/bin/liquid $out/bin
wrapProgram $out/bin/liquid --prefix PATH : ${pkgs.z3}/bin
'';
ghc = pkgs.haskellPackages.ghcWithPackages (ps: with ps; [
vector
]);
in
pkgs.stdenv.mkDerivation {
name = "my-haskell-env-0";
buildInputs = [ ghc liquid ];
shellHook = "eval $(egrep ^export ${ghc}/bin/ghc)";
}