无法重新编译带有Nix覆盖的coreutils

问题描述 投票:0回答:1

正如在本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个回答
0
投票

好吧,我认为将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
© www.soinside.com 2019 - 2024. All rights reserved.