I'm trying to use liquidhaskell on NixOS. I can install the package (liquidhaskell-0.8.2.3), though not the cabal integration, because it requires cabal 1.18-1.25, but I have cabal 2.0.1.0 .
I have installed the liquidhaskell package as part of a ghc-with-packages setup:
[~:0]$ readlink $( type -p liquid )
/nix/store/pdbzl0p6k1klmajx969b6vvwyw9w0s6b-ghc-8.2.2-with-packages/bin/liquid
Among many others, the package text also installed in this set:
[proclib:1]$ ls -ld /nix/store/pdbzl0p6k1klmajx969b6vvwyw9w0s6b-ghc-8.2.2-with-packages/lib/ghc-8.2.2/text-1.2.2.2/
dr-xr-xr-x 3 root root 68 Jan 1 1970 /nix/store/pdbzl0p6k1klmajx969b6vvwyw9w0s6b-ghc-8.2.2-with-packages/lib/ghc-8.2.2/text-1.2.2.2/
However, liquid cannot see this:
[proclib:1]$ liquid ~/bin/h/nix.hs
LiquidHaskell Version 0.8.2.3
Copyright 2013-18 Regents of the University of California. All Rights Reserved.
liquid: Main: Could not find module ‘Data.Text’
Perhaps you meant Data.Set (from containers-0.5.10.2)
Use -v to see a list of the files searched for.
The above is not part of a cabal package (to try to eliminate the cabal thing from the equation).
I've tried playing with nix-shell to make this work, but either nix-shell or liquid break down on language pragmas:
[~:0]$ nix-shell -p myHaskellEnv --run liquid ~/bin/h/nix.hs
/nix/store/q1cwqhb6v8yx8vy4s5p6sxrq8s0bnqmy-nix.hs: line 5: {-#: command not found
Any help gratefully received.
The problem seems to be that liquid haskell ignores the ghcWithPackages wrappers, because it uses the GHC API directly. You can work around this as follows, based on this thread.
nix-shell -p 'haskellPackages.ghcWithPackages(pkgs:[pkgs.text (pkgs.liquidhaskell)])' -p z3 --run 'liquid --ghc-option="-package-db=$(ghc-pkg list | head -n 1)" ./hellotext.hs'
Or somewhat equivalently,
nix-shell -p 'haskellPackages.ghcWithPackages(pkgs:[pkgs.text])' -p z3 -p haskellPackages.liquidhaskell --run 'NIX_GHC_LIBDIR=$(ghc-pkg list | head -n 1)/.. liquid ./hellotext.hs'
which suggests that it will work out of the box when you're in a nix-shell
based on a cabal2nix
package.