2017-09-30 47 views
0

的阴谋没有在下面的例子中发现的问题是,如何正确的例子,这样的阴谋被发现。如何制作cabal在straigthforward nix-pill 8.1模仿中找到?

这个例子是the nix pill 8.1非常straigthforward修饰。在nix-repl,打字:l <nixpkgs>然后"${cabal-install}"给予卖场里小集团安装是它包含的子迪尔斯有彬有含阴谋可执行的路径。即

> /nix/store/pathtocabal-install/bin/cabal -v 
cabal-install version 2.0.0.0 
compiled using version 2.0.0.2 of the Cabal library 

下面您应该找到与“make c”示例对应的文件。

有了它们,在

> nix-build hello.nix 

不起作用。它首先告诉打造“这些推导”,然后说

hello_builder.sh: line 2: cabal: command not found 

我怀疑$小集团安装/ bin中是一个错误的方式来引用的阴谋,但是,nix-repl发现其商店路径。

hello_builder.sh比在c例子更短。请注意,安装部件仍然缺失(首先应该找到建造者来找到cabal)。不需要也许binutils的 -

export PATH="$coreutils/bin:$ghc/bin:$cabal-install/bin:$binutils/bin" 
cabal build hello 

hello.nix。

with (import <nixpkgs> {}); 
derivation { 
    name = "hello"; 
    builder = "${bash}/bin/bash"; 
    args = [ ./hello_builder.sh ]; 
    inherit binutils coreutils ghc cabal-install; 
    src = ./hello.cabal; 
    system = builtins.currentSystem; 
} 

hello.cabal - 在nix-shell与阴谋安装和GHC,这个工程。

name:    hello 
version:    0.1.0.0 
build-type:   Simple 
cabal-version:  >=1.24 

executable hello 
    main-is:    hello.hs 
    default-language: Haskell2010 
    build-depends:  base    >=4.9 && <4.10 

hello.hs

module Main where 

main :: IO() 
main = putStrLn "Hello there!" 

后期补充:

通过添加echo $PATH的建设者,我们可以看到,路径是不正确的。它是/nix/store/...coreutils-8.28/bin:/nix/store...ghc-8.0.2/bin:-install/bin:/nix/store/...binutils-2.28.1/bin。那里$cabal变成一个空字符串,它不是指$cabal-install。因此,cabal可执行文件没有正确的存储路径。

这个答案的原因部分以及如何纠正它保持的一部分。而开放的原因 - 部分是,为什么inherit cabal-install不能在这里使用。

回答

1

的问题inherit cabal-install;cabal-install不是BASH有效的变量名。 Nix将提供的集合中的密钥转换为BASH中的变量,即derivation

而不是inherit cabal-install;你可以做一些像cabal_install = cabal-install;,然后在你的建设者使用cabal_install