2

背景

当我为 Nixpkgs添加第一个Overlay时,我发现为不同版本构建了一堆系统实用程序:

these derivations will be built:
  /nix/store/028dqnwq36xja16gba3gckq5mcprpn06-postfix-main.cf.drv
  /nix/store/b2sch2538ny2drdf9zzknf38grn8d8r3-pcre-8.42.drv
  /nix/store/i1k9ksk32ca441zap40z3zddy7bhqx3n-zlib-1.2.11.drv
  /nix/store/sypawsb3cwqnnhdl1barv2d8nyvbsxyv-coreutils-8.29.drv
  /nix/store/xa4vnajxck2zgvjwp7l71lm11hqnz32r-findutils-4.6.0.drv
...

这是时间和空间的消耗。我试图弄清楚发生了什么,然后以这个问题告终。

概括

叠加层的思想是所有叠加层都应用后的累加结果,而叠加层self是应用前一个叠加层的结果。superselfsuper

我认为一个未被触及的属性在 and 之间是相同的selfsuper但有些不是。

let
  nixpkgs = import <nixpkgs> {
    overlays = [
      # This overlay obtains self.bash and super.bash, and save them under the
      # attrs "bash-from-self" and "bash-from-super" for further examination
      (self: super: {
        bash-from-self = self.bash;
        bash-from-super = super.bash;
      })
    ];
  };
  # Retrieve bash-from-self (self.bash) and bash-from-super (super.bash)
  # from the overlayed nixpkgs
  inherit (nixpkgs) bash-from-self bash-from-super;
in {
  # Check if bash-from-self (self.bash) and bash-from-super (super.bash)
  # are same
  isBashSame = (bash-from-self == bash-from-super);
  inherit bash-from-self bash-from-super;
}

以上评估为:

{ isBashSame = false; 
  bash-from-self = «derivation /nix/store/zvy7mbpxqlplqpflqn5xk9szx25s4mhg-bash-4.4-p23.drv»;
  bash-from-super = «derivation /nix/store/2i91sj16snsphvjrbsa62z8m4zhs261c-bash-4.4-p23.drv»; }

显示self.bashsuper.bash不一样,即使bash在任何叠加层中都没有触及该属性。为什么会发生这种情况,或者确实缺少一些概念?


细节

更多不同的属性

除了 之外bash,还有更多不同的属性:

let
  isAttrSame =
    attrName:
    let
      nixpkgs = import <nixpkgs> {
        overlays = [
          (_self: _super: { inherit _self _super; })
        ];
      };
      self = nixpkgs._self."${attrName}";
      super = nixpkgs._super."${attrName}";
      isSame = self == super;
    in
      isSame
  ;
in {
  coreutils = isAttrSame "coreutils";
  bash = isAttrSame "bash";
  zsh = isAttrSame "zsh";
  zlib = isAttrSame "zlib";
  stdenv = isAttrSame "stdenv";
  findutils = isAttrSame "findutils";
  gnutar = isAttrSame "gnutar";
  gcc = isAttrSame "gcc";
}
{
  bash = false;
  coreutils = false;
  findutils = false;
  gcc = true;
  gnutar = true;
  stdenv = true;
  zlib = false;
  zsh = true;
}

的建造者self.bashsuper.bash

let
  nixpkgs = import <nixpkgs> {
    overlays = [
      (self: super: {
        bash-from-self = self.bash;
        bash-from-super = super.bash;
      })
    ];
  };
  inherit (nixpkgs) bash-from-self bash-from-super;
in {
  bash-from-self-builder = bash-from-self.drvAttrs.builder;
  bash-from-super-builder = bash-from-super.drvAttrs.builder;
  bash-from-self-outPath = bash-from-self.outPath;
  bash-from-super-outPath = bash-from-super.outPath;
}
{ bash-from-self-builder = "/nix/store/2ws9cmamvr7xyvdg4d2nnd1bmr1zjrrq-bootstrap-tools/bin/bash";
  bash-from-self-outPath = "/nix/store/06z61jbgs0vkw4i9cqqf9yl7zsfkkhw2-bash-4.4-p23";
  bash-from-super-builder = "/nix/store/06z61jbgs0vkw4i9cqqf9yl7zsfkkhw2-bash-4.4-p23/bin/bash";
  bash-from-super-outPath = "/nix/store/2avim7j13k75k26w18g6br8gai869nm9-bash-4.4-p23"; }

bash-from-self-outPathbash-from-super-builder( 06z61...khw2-bash-4.4-p23)。

那么super.bash用于self.bash构建自身,产生另一个 bash ( 2avim...9nm9-bash-4.4-p23)?

bootstrap-tools/bash--builds--> self.bash--builds-->super.bash

为什么这是一个问题

我希望我在叠加层中定义的一些包依赖于bash,coreutils和东西。我想使用它们直接提供的原始版本<nixpkgs>,而不是那些可能被以后的覆盖覆盖的版本。因此,在这种情况下,似乎我应该选择super.*而不是self.*成为依赖项。

但是有些super.stuff不是原始的nixpkgs.stuff,这会导致重建它们,因为没有二进制缓存并且浪费磁盘空间。并且self.stuff可能会被以后的覆盖覆盖。我能做些什么?

4

0 回答 0