Nix不会触发coreutils的重建 [英] Nix does not trigger rebuild of coreutils

查看:121
本文介绍了Nix不会触发coreutils的重建的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Devuan GNU / Linux系统(x86_64)上运行Nix,并在〜/ .nixpkgs / config.nix 中运行,如九粒药

I am running Nix on top of Devuan GNU/Linux system (x86_64), with following ~/.nixpkgs/config.nix, as documented in Nix Pills:

{
  packageOverrides = pkgs: {
    coreutils = pkgs.coreutils.override {
      aclSupport = false;
      attrSupport = false;
      selinuxSupport = false;
    };
    coreutils2 = pkgs.coreutils.override {
      aclSupport = false;
      attrSupport = false;
      selinuxSupport = false;
    };
    w3m = pkgs.w3m.override {
      graphicsSupport = false;
      imlib2 = null;
      x11Support = false;
      mouseSupport = true;
    };
  };
}

但是当我运行 nix-env -iA nixpkgs .coreutils ,Nix安装了coreutils的普通版,并启用了可选功能:

But when I run nix-env -iA nixpkgs.coreutils, Nix installs stock version of coreutils, with optional features enabled:

$ nix-env -iA nixpkgs.coreutils
replacing old 'coreutils-8.31'
installing 'coreutils-8.31'
$ ldd /home/iu/.nix-profile/bin/ls |grep libattr
        libattr.so.1 => /nix/store/5xwmn6ai8c42j84k6gdzja0lnkdi3c60-attr-2.4.48/lib/libattr.so.1
(0x00007f0354e7f000)

但是如果我通过其他名称指代相同的派生(参照透明性):

But if I refer to same derivation (referential transparency) via other name:

$ nix-env -iA nixpkgs.coreutils2

Nix从源代码开始重建,结果生成二进制文件,编译后 without 可选功能,按要求进行。更为神秘的是, w3m 工程的主要构建选项和 do 触发重建。

Nix starts rebuild from source, which results in binaries, compiled without optional features, just as requested. What is even more mysterious, overriding build options for w3m works and do trigger rebuild.

此外,我注意到 gnutar 的行为也很奇怪。 coreutils gnutar 对于Nix本身是必不可少的吗?如何以预期的方式制作 coreutils

Also, I noticed same strange behavior with gnutar. Is is somehow related to the fact that coreutils and gnutar are essential to Nix itself? How can I make coreutils in expected way?

推荐答案

一个最终覆盖之后应用您的叠加层。 (您正在使用 packageOverrides 本质上成为第一个用户覆盖)

This happens because one final overlay is applied after your overlays. (You're using packageOverrides which becomes essentially the first user overlay)

引用提交


stdenvOverrides叠加层用于在
引导过程中通过stdenv.overrides向前推进软件包。这些软件包已经在上一个提升阶段将
的叠加层应用于它们。如果
stdenvOverrides不在叠加层堆栈的最后,则所有剩余的
叠加层将再次应用于这些包。

The stdenvOverrides overlay is used to bring packages forward during bootstrapping via stdenv.overrides. These packages have already had the overlays applied to them in the previous boostrapping stage. If stdenvOverrides is not last in the overlays stack, all remaining overlays will windup being applied again to these packages.



此叠加层还设置了

nutar

$ nix repl '<nixpkgs>'
nix-repl> lib.attrNames (stdenv.overrides pkgs pkgs)
[ "acl" "attr" "bash" "binutils" "binutils-unwrapped" "bzip2" "coreutils" "diffutils" "findutils" "gawk" "gcc" "glibc" "gnugrep" "gnumake" "gnupatch" "gnused" "gnutar" "gzip" "patchelf" "pcre" "xz" "zlib" ]

好消息是您可以使用普通叠加层配置最后一个叠加层。令人费解的,但它可以起作用:

The "good" news is you can use a normal overlay to configure the last overlay. It's convoluted but it works:

nix-repl> (import <nixpkgs> { overlays = [ (self: super: { stdenv = super.stdenv // { overrides = self2: super2: super.stdenv.overrides self2 super2 // { coreutils = "put your coreutils here"; }; }; }) ]; }).coreutils
"put your coreutils here"

我建议使用覆盖而不是 packageOverrides 来确保这种情况发生在最后一个用户覆盖中。
因此,您的覆盖层将类似于:

I recommend using overlays instead of packageOverrides to make sure this happens in the last "user" overlay. So your overlay would be similar to:

_: super:
let
  coreutils = pkgs.coreutils.override {
    aclSupport = false;
    attrSupport = false;
    selinuxSupport = false;
  };
in
{
  # Overrides for stuff from stdenv go here. They're applied last
  # so we use the same stdenv for builds but a custom coreutils etc for
  # our system. This allows use to still use cache.nixos.org.
  stdenv = super.stdenv // {
    overrides = self2: super2: super.stdenv.overrides self2 super2 // {
      inherit coreutils;
    };
  };

  w3m = ...;
}

这篇关于Nix不会触发coreutils的重建的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆