Build 无法使用Nix重写重新编译coreutils

Build 无法使用Nix重写重新编译coreutils,build,nix,gnu-coreutils,Build,Nix,Gnu Coreutils,正如本文所讨论的,对Nix本身至关重要的派生的重写属性比通常更复杂 我尝试使用示例中提供的代码,但遇到了更多问题。这是我的~/.config/nixpkgs/overlays/main.nix: _: super: let coreutils = super.coreutils.override { aclSupport = false; }; in { stdenv = super.stdenv // { overrides = self2: super2: super

正如本文所讨论的,对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
我无法理解发生了什么,这种空强制发生在
安装后的某个地方。好的,我也尝试覆盖
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呢?

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

您需要克隆nixpkgs,签出您正在执行的同一个提交,并检查该文件,该文件类似于:

    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