2017-11-19 23 views
4

nix-env -i ghc으로 ghc를 설치할 수있었습니다.Nixos에서 GHCi를 통해 액세스 할 수있는 Haskell 라이브러리를 어떻게 설치할 수 있습니까?

지금 하스켈 라이브러리를 설치하고 싶습니다. 어떻게해야합니까? 예 : turtle (https://hackage.haskell.org/package/turtle) 라이브러리

나는 그러나 ghciimport Turtle 실패 실행 nix-env -f "<nixpkgs>" -iA haskellPackages.turtle을 실행했습니다

Prelude> import Turtle 

<no location info>: error: 
    Could not find module ‘Turtle’ 
    It is not a module in the current program, or in any known package. 

출력 ghc-pkg list의 :

/nix/store/fvf278s3lqsjv488ahhdi8jx6i0qzsr9-ghc-8.0.2/lib/ghc-8.0.2/package.conf.d  
Cabal-1.24.2.0       
array-0.5.1.1       
base-4.9.1.0        
binary-0.8.3.0       
bytestring-0.10.8.1      
containers-0.5.7.1      
deepseq-1.4.2.0       
directory-1.3.0.0      
filepath-1.4.1.1       
ghc-8.0.2        
ghc-boot-8.0.2       
ghc-boot-th-8.0.2      
ghc-prim-0.5.0.0       
ghci-8.0.2        
haskeline-0.7.3.0      
hoopl-3.10.2.1       
hpc-0.6.0.3        
integer-gmp-1.0.0.1      
pretty-1.1.3.3       
process-1.4.3.0       
rts-1.0         
template-haskell-2.11.1.0    
terminfo-0.4.0.2       
time-1.6.0.1        
transformers-0.5.2.0      
unix-2.7.2.1        
xhtml-3000.2.1 

답변

3

이 때문에 순도의 NixOS에 다르게 작동합니다. NixOS의 GHC는 자신의 불변 설치 디렉토리와 사용자가 설치 한 패키지를 cabal install으로 만 볼 것입니다.

ghci을 실행할 때 멋진 패키지 세트를 제공하는 GHC 래퍼를 사용자 프로필에 설치하면됩니다.

파일 my-ghc.nix 만듭니다

(import <nixpkgs> {}).haskellPackages.ghcWithPackages (hpkgs: with hpkgs; [ 
    lens 
    aeson 
    turtle 
]) 

제거 이름 충돌 방지하기 이전 시도 :

nix-env -e ghc turtle 

은, 랩 GHC를 설치

nix-env -if my-ghc.nix 

당신은 파일을 편집 할 수 있습니다를 그 명령을 다시 실행하십시오.

프로젝트를 진행할 때 cabal2nixnix-shell을 선호합니다. (소개는 Oliver Charles' blog post 참조)