gpt4 book ai didi

nix - `nix-build hello.nix`时失败

转载 作者:行者123 更新时间:2023-12-05 05:13:41 27 4
gpt4 key购买 nike

我按照 http://lethalman.blogspot.com/2014/08/nix-pill-8-generic-builders.html 上的步骤操作构建 GNU Hello,这是我用来构建 GNU hello 2.9 的文件:

$ wget -c http://ftp.gnu.org/gnu/hello/hello-2.9.tar.gz

你好.nix:

$ cat hello.nix
let
pkgs = import <nixpkgs> {};
mkDerivation = import ./autotools.nix pkgs;
in mkDerivation {
name = "hello";
src = ./hello-2.9.tar.gz;
}

autotools.nix:

$ cat autotools.nix
pkgs: attrs:
with pkgs;
let defaultAttrs = {
builder = "${bash}/bin/bash";
args = [ ./builder.sh ];
baseInputs = [ gnutar gzip gnumake gcc binutils coreutils gawk gnused gnugrep ];
buildInputs = [];
system = builtins.currentSystem;
};
in
derivation (defaultAttrs // attrs)

构建器.sh:

$ cat builder.sh
set -e
unset PATH
for p in $buildInputs; do
export PATH=$p/bin${PATH:+:}$PATH
done

tar -xf $src

for d in *; do
if [ -d "$d" ]; then
cd "$d"
break
fi
done

./configure --prefix=$out
make
make install

错误信息:

$ nix-build hello.nix
these derivations will be built:
/nix/store/d84l57agx3rmw00lxs8gjlw8srmx1bh9-hello.drv
building '/nix/store/d84l57agx3rmw00lxs8gjlw8srmx1bh9-hello.drv'...
/nix/store/vv3xqdggviqqbvym25jf2pwv575y9j1r-builder.sh: line 7: tar: No such file or directory
builder for '/nix/store/d84l57agx3rmw00lxs8gjlw8srmx1bh9-hello.drv' failed with exit code 127
error: build of '/nix/store/d84l57agx3rmw00lxs8gjlw8srmx1bh9-hello.drv' failed

autotools.nix 中似乎有gnutar,但构建器仍然提示tar: No such file or directory,这是为什么呢?

最佳答案

问题可能是 gnutarbaseInputs 列表中,而您从中构建 PATH 的 buildInputs 列表完全是空的,所以你的路径上不会有任何东西。尝试更改 shell 脚本中的 for 行,以便它使用两个列表的连接来构建路径:

for p in $baseInputs $buildInputs; do

您可以将 echo $PATH 添加到构建器脚本中以调试此类问题。

这就是博文作者要求您在博文中的这句话中做的事情:

Complete the new builder.sh by adding $baseInputs in the for loop together with $buildInputs.

关于nix - `nix-build hello.nix`时失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53313902/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com