Nix-shell as #! interpreter for runghc

I am trying to use nix-shell as #! wrapper for runghc as indicated in the man page. But he cannot find the library. In the following example, cutting from manpage

#! /usr/bin/env nix-shell
#! nix-shell -i runghc -p haskellPackages.HTTP

import Network.HTTP

main = return ()

I get the following result:

[~:0]$ ./nixshelltest 

nixshelltest:4:1: error:
    Failed to load interface for ‘Network.HTTP’
    Use -v to see a list of the files searched for.
[~:1]$ 

in my opinion, exactly what nix-shell -p should avoid.

Am I doing something wrong skipping a point or is there a mistake? This is on both the nixOS 17.03 host and the host running nix 17.09 on top of Ubuntu.

Thank,

+4
source share
1 answer

There is no step in the environment you use to run the script. He received the GHC and the HTTP packet, but the compiler does not know about the packet.

GHC nix "" , . , " " , , . , GHC , GHC. GHC GHC , ​​, nix . Nix GHC, , , , .

, , "" GHC, , . GHC, , GHC. , , , - GHC, .

, script, , , ; HTTP. script, command not found: runghc. runghc , , (, , GHC ?), GHC HTTP . nix-shell .

:

#! nix-shell -i runghc -p 'ghc.withPackages (ps: [ ps.HTTP ])'

ghc HTTP; ghc.withPackages nix, GHC, HTTP Haskell. "" GHC , HTTP .

Haskell (, nix-shell, , ), withPackages, , , - . , , nix GHC .

+4

Source: https://habr.com/ru/post/1681153/


All Articles