[Nix-dev] Haskell in nix-shell scripts (was: Nix 1.9 released)
Peter Simons
simons at cryp.to
Sat Jun 13 20:44:40 CEST 2015
Hi,
> users [of nixos-unstable] have to use a slightly modified version of
> the script that looks as follows:
>
> | #! /usr/bin/env nix-shell
> | #! nix-shell -i runghc -p "haskellPackages.ghcWithPackages (p: [p.HTTP])"
> [...]
it turns out that script won't work either. It seemed to work when I
tested it on my machine, but that was only because I had "runghc" in
$PATH already. Adding "--pure" reveals the issue:
| #! /usr/bin/env nix-shell
| #! nix-shell --pure -i runghc -p "haskellPackages.ghcWithPackages (p: [p.HTTP])"
|
| import Network.HTTP
|
| main = do
| resp <- Network.HTTP.simpleHTTP (getRequest "http://nixos.org/")
| body <- getResponseBody resp
| print (take 100 body)
When run, that script fails as follows:
$ /tmp/test
bash: exec: runghc: not found
The exact same mechanism works fine in a normal shell, however:
$ nix-shell --pure -p "haskellPackages.ghcWithPackages (p: [p.HTTP])" --run "ghc-pkg list HTTP"
/nix/store/qxwql6in0v13i83p8vrvm7ma9i2aash4-ghc-7.10.1/lib/ghc-7.10.1/package.conf.d
HTTP-4000.2.19
I've tried for a while now, but I could not figure out how to make a
non-trivial Haskell script work with nix-shell.
Best regards,
Peter
More information about the nix-dev
mailing list