[Nix-dev] Haskell in nix-shell scripts

Eelco Dolstra eelco.dolstra at logicblox.com
Mon Jun 15 10:50:02 CEST 2015


Hi,

On 13/06/15 20:44, Peter Simons wrote:

>  > 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])"

The problem is that quoted arguments don't work here at the moment.

As a workaround, you can put this in the script:

  #! /usr/bin/env nix-shell
  #! nix-shell -i runghc ./script.nix

and this in "script.nix":

  with import (fetchTarball
https://github.com/NixOS/nixpkgs-channels/archive/nixos-unstable.tar.gz) {};

  runCommand "dummy"
    { buildInputs =
        [ (haskellPackages.ghcWithPackages (p: [p.HTTP p.tagsoup])) ];
    } ""

-- 
Eelco Dolstra | LogicBlox, Inc. | http://nixos.org/~eelco/


More information about the nix-dev mailing list