【问题标题】:Failed to re-compile coreutils with overrides with Nix使用 Nix 重新编译 coreutils 失败
【发布时间】:2019-11-09 02:04:45
【问题描述】:

正如question 中所讨论的,重写对 Nix 本身至关重要的派生属性比平常更复杂。

我尝试使用示例中提供的代码,但遇到了更多问题。这是我的~/.config/nixpkgs/overlays/main.nix

_: super:
let coreutils = super.coreutils.override { aclSupport = false; };
in
{
  stdenv = super.stdenv // {
    overrides = self2: super2:
      super.stdenv.overrides self2 super2 // {
        inherit coreutils;
    };
  };
}

现在,当我尝试使用 nix-env -iA nixpkgs.coreutils --show-trace 安装我的 coreutils 版本时,我收到以下错误:

replacing old 'coreutils-8.31'
installing 'coreutils-8.31'
error: while evaluating the attribute 'buildInputs' of the derivation 'coreutils-8.31' at /nix/store/dmdqvlxfk7c5gj4jg8iv77d8bmyk3c12-nixpkgs-20.03pre199995.895874d2145/nixpkgs/pkgs/stdenv/generic/make-derivation.nix:191:11:
while evaluating the attribute 'builder' of the derivation 'gmp-6.1.2' at /nix/store/dmdqvlxfk7c5gj4jg8iv77d8bmyk3c12-nixpkgs-20.03pre199995.895874d2145/nixpkgs/pkgs/development/libraries/gmp/6.x.nix:9:3:
while evaluating the attribute 'shell' at /nix/store/dmdqvlxfk7c5gj4jg8iv77d8bmyk3c12-nixpkgs-20.03pre199995.895874d2145/nixpkgs/pkgs/stdenv/generic/default.nix:103:14:
while evaluating the attribute 'gcc' at /nix/store/dmdqvlxfk7c5gj4jg8iv77d8bmyk3c12-nixpkgs-20.03pre199995.895874d2145/nixpkgs/pkgs/stdenv/linux/default.nix:290:7:
while evaluating 'makeOverridable' at /nix/store/dmdqvlxfk7c5gj4jg8iv77d8bmyk3c12-nixpkgs-20.03pre199995.895874d2145/nixpkgs/lib/customisation.nix:67:24, called from /nix/store/dmdqvlxfk7c5gj4jg8iv77d8bmyk3c12-nixpkgs-20.03pre199995.895874d2145/nixpkgs/pkgs/stdenv/linux/default.nix:290:13:
while evaluating anonymous function at /nix/store/dmdqvlxfk7c5gj4jg8iv77d8bmyk3c12-nixpkgs-20.03pre199995.895874d2145/nixpkgs/pkgs/build-support/cc-wrapper/default.nix:8:1, called from /nix/store/dmdqvlxfk7c5gj4jg8iv77d8bmyk3c12-nixpkgs-20.03pre199995.895874d2145/nixpkgs/lib/customisation.nix:69:16:
while evaluating the attribute 'gcc-unwrapped' at /nix/store/dmdqvlxfk7c5gj4jg8iv77d8bmyk3c12-nixpkgs-20.03pre199995.895874d2145/nixpkgs/pkgs/stdenv/linux/default.nix:258:7:
while evaluating the attribute 'gcc-unwrapped.override' at /nix/store/dmdqvlxfk7c5gj4jg8iv77d8bmyk3c12-nixpkgs-20.03pre199995.895874d2145/nixpkgs/pkgs/top-level/all-packages.nix:7666:3:
while evaluating 'addMetaAttrs' at /nix/store/dmdqvlxfk7c5gj4jg8iv77d8bmyk3c12-nixpkgs-20.03pre199995.895874d2145/nixpkgs/lib/meta.nix:15:28, called from /nix/store/dmdqvlxfk7c5gj4jg8iv77d8bmyk3c12-nixpkgs-20.03pre199995.895874d2145/nixpkgs/pkgs/top-level/all-packages.nix:7825:10:
while evaluating 'wrapCC' at /nix/store/dmdqvlxfk7c5gj4jg8iv77d8bmyk3c12-nixpkgs-20.03pre199995.895874d2145/nixpkgs/pkgs/top-level/all-packages.nix:8688:12, called from /nix/store/dmdqvlxfk7c5gj4jg8iv77d8bmyk3c12-nixpkgs-20.03pre199995.895874d2145/nixpkgs/pkgs/top-level/all-packages.nix:7825:19:
while evaluating 'wrapCCWith' at /nix/store/dmdqvlxfk7c5gj4jg8iv77d8bmyk3c12-nixpkgs-20.03pre199995.895874d2145/nixpkgs/pkgs/top-level/all-packages.nix:8667:5, called from /nix/store/dmdqvlxfk7c5gj4jg8iv77d8bmyk3c12-nixpkgs-20.03pre199995.895874d2145/nixpkgs/pkgs/top-level/all-packages.nix:8688:16:
while evaluating 'callPackageWith' at /nix/store/dmdqvlxfk7c5gj4jg8iv77d8bmyk3c12-nixpkgs-20.03pre199995.895874d2145/nixpkgs/lib/customisation.nix:117:35, called from /nix/store/dmdqvlxfk7c5gj4jg8iv77d8bmyk3c12-nixpkgs-20.03pre199995.895874d2145/nixpkgs/pkgs/top-level/all-packages.nix:8676:7:
while evaluating 'makeOverridable' at /nix/store/dmdqvlxfk7c5gj4jg8iv77d8bmyk3c12-nixpkgs-20.03pre199995.895874d2145/nixpkgs/lib/customisation.nix:67:24, called from /nix/store/dmdqvlxfk7c5gj4jg8iv77d8bmyk3c12-nixpkgs-20.03pre199995.895874d2145/nixpkgs/lib/customisation.nix:121:8:
while evaluating anonymous function at /nix/store/dmdqvlxfk7c5gj4jg8iv77d8bmyk3c12-nixpkgs-20.03pre199995.895874d2145/nixpkgs/pkgs/build-support/cc-wrapper/default.nix:8:1, called from /nix/store/dmdqvlxfk7c5gj4jg8iv77d8bmyk3c12-nixpkgs-20.03pre199995.895874d2145/nixpkgs/lib/customisation.nix:69:16:
while evaluating the attribute 'cc.nativeTools' at /nix/store/dmdqvlxfk7c5gj4jg8iv77d8bmyk3c12-nixpkgs-20.03pre199995.895874d2145/nixpkgs/pkgs/stdenv/generic/default.nix:148:14:
while evaluating 'makeOverridable' at /nix/store/dmdqvlxfk7c5gj4jg8iv77d8bmyk3c12-nixpkgs-20.03pre199995.895874d2145/nixpkgs/lib/customisation.nix:67:24, called from /nix/store/dmdqvlxfk7c5gj4jg8iv77d8bmyk3c12-nixpkgs-20.03pre199995.895874d2145/nixpkgs/pkgs/stdenv/linux/default.nix:101:19:
while evaluating anonymous function at /nix/store/dmdqvlxfk7c5gj4jg8iv77d8bmyk3c12-nixpkgs-20.03pre199995.895874d2145/nixpkgs/pkgs/build-support/cc-wrapper/default.nix:8:1, called from /nix/store/dmdqvlxfk7c5gj4jg8iv77d8bmyk3c12-nixpkgs-20.03pre199995.895874d2145/nixpkgs/lib/customisation.nix:69:16:
while evaluating the attribute 'buildInputs' of the derivation 'glibc-2.27' at /nix/store/dmdqvlxfk7c5gj4jg8iv77d8bmyk3c12-nixpkgs-20.03pre199995.895874d2145/nixpkgs/pkgs/development/libraries/glibc/common.nix:167:3:
while evaluating the attribute 'depsBuildBuild' of the derivation 'linux-headers-4.19.16' at /nix/store/dmdqvlxfk7c5gj4jg8iv77d8bmyk3c12-nixpkgs-20.03pre199995.895874d2145/nixpkgs/pkgs/stdenv/generic/make-derivation.nix:191:11:
while evaluating the attribute 'bintools' of the derivation 'bootstrap-stage2-gcc-wrapper' at /nix/store/dmdqvlxfk7c5gj4jg8iv77d8bmyk3c12-nixpkgs-20.03pre199995.895874d2145/nixpkgs/pkgs/build-support/cc-wrapper/default.nix:96:3:
while evaluating the attribute 'bintools_bin' of the derivation 'binutils-wrapper-2.31.1' at /nix/store/dmdqvlxfk7c5gj4jg8iv77d8bmyk3c12-nixpkgs-20.03pre199995.895874d2145/nixpkgs/pkgs/build-support/bintools-wrapper/default.nix:76:3:
while evaluating the attribute 'buildInputs' of the derivation 'binutils-2.31.1' at /nix/store/dmdqvlxfk7c5gj4jg8iv77d8bmyk3c12-nixpkgs-20.03pre199995.895874d2145/nixpkgs/pkgs/development/tools/misc/binutils/default.nix:26:3:
while evaluating the attribute 'stdenv' of the derivation 'zlib-1.2.11' at /nix/store/dmdqvlxfk7c5gj4jg8iv77d8bmyk3c12-nixpkgs-20.03pre199995.895874d2145/nixpkgs/pkgs/development/libraries/zlib/default.nix:18:3:
while evaluating the attribute 'defaultNativeBuildInputs' of the derivation 'bootstrap-stage1-stdenv-linux' at /nix/store/dmdqvlxfk7c5gj4jg8iv77d8bmyk3c12-nixpkgs-20.03pre199995.895874d2145/nixpkgs/pkgs/stdenv/generic/default.nix:73:14:
while evaluating the attribute 'bintools' of the derivation 'bootstrap-stage1-gcc-wrapper' at /nix/store/dmdqvlxfk7c5gj4jg8iv77d8bmyk3c12-nixpkgs-20.03pre199995.895874d2145/nixpkgs/pkgs/build-support/cc-wrapper/default.nix:96:3:
while evaluating the attribute 'coreutils_bin' of the derivation 'bootstrap-stage0-binutils-wrapper' at /nix/store/dmdqvlxfk7c5gj4jg8iv77d8bmyk3c12-nixpkgs-20.03pre199995.895874d2145/nixpkgs/pkgs/build-support/bintools-wrapper/default.nix:76:3:
while evaluating the attribute 'buildInputs' of the derivation 'coreutils-8.31' at /nix/store/dmdqvlxfk7c5gj4jg8iv77d8bmyk3c12-nixpkgs-20.03pre199995.895874d2145/nixpkgs/pkgs/stdenv/generic/make-derivation.nix:191:11:
while evaluating the attribute 'nativeBuildInputs' of the derivation 'attr-2.4.48' at /nix/store/dmdqvlxfk7c5gj4jg8iv77d8bmyk3c12-nixpkgs-20.03pre199995.895874d2145/nixpkgs/pkgs/development/libraries/attr/default.nix:4:3:
while evaluating the attribute 'nativeBuildInputs' of the derivation 'gettext-0.19.8.1' at /nix/store/dmdqvlxfk7c5gj4jg8iv77d8bmyk3c12-nixpkgs-20.03pre199995.895874d2145/nixpkgs/pkgs/stdenv/generic/make-derivation.nix:191:11:
while evaluating the attribute 'nativeBuildInputs' of the derivation 'bison-3.4.2' at /nix/store/dmdqvlxfk7c5gj4jg8iv77d8bmyk3c12-nixpkgs-20.03pre199995.895874d2145/nixpkgs/pkgs/stdenv/generic/make-derivation.nix:191:11:
while evaluating the attribute 'postInstall' of the derivation 'perl-5.30.0' at /nix/store/dmdqvlxfk7c5gj4jg8iv77d8bmyk3c12-nixpkgs-20.03pre199995.895874d2145/nixpkgs/pkgs/development/interpreters/perl/default.nix:29:5:
cannot coerce null to a string, at /nix/store/dmdqvlxfk7c5gj4jg8iv77d8bmyk3c12-nixpkgs-20.03pre199995.895874d2145/nixpkgs/pkgs/development/interpreters/perl/default.nix:128:7

我不明白发生了什么,这种空强制发生在postInstall 的某个地方。好的,我也尝试覆盖perl

_: super:
let coreutils = super.coreutils.override { aclSupport = false; };
in
{
  stdenv = super.stdenv // {
    overrides = self2: super2:
      super.stdenv.overrides self2 super2 // {
        inherit coreutils;
        perl = super.perl.overrideAttrs (_: { postInstall = ""; });
    };
  };
}

现在,尝试安装 coreutils 会触发 perl 的重建(当然),这会失败并出现有关缺少 C 编译器的错误:

./UU/checkcc: line 10: cc: command not found

我在这里卡住了。那么,如何覆盖coreutils

【问题讨论】:

    标签: build nix gnu-coreutils


    【解决方案1】:

    我认为将 perls postInstall 设置为 "" 是导致错误的原因。我会忽略这一点并回到第一个错误。然后在该错误的位置查找 nix 文件。

    您需要克隆 nixpkgs,签出您正在执行的同一提交,然后检查文件,该文件如下所示:

    https://github.com/NixOS/nixpkgs/blob/bc77ec7e560672ff9f8a5b5e60f228818d230d4b/pkgs/development/interpreters/perl/default.nix#L127

        postInstall =
          ''
            # Remove dependency between "out" and "man" outputs.
            rm "$out"/lib/perl5/*/*/.packlist
            # Remove dependencies on glibc and gcc
            sed "/ *libpth =>/c    libpth => ' '," \
              -i "$out"/lib/perl5/*/*/Config.pm
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-07-20
      • 1970-01-01
      • 2021-10-07
      • 1970-01-01
      • 1970-01-01
      • 2021-10-28
      相关资源
      最近更新 更多