Finding all Nix build time dependencies, including bootstrapping ones

huangapple go评论74阅读模式
英文:

Finding all Nix build time dependencies, including bootstrapping ones

问题

我试图设置一个包含构建简单派生所需的所有存储路径的 Nix 缓存。目标是使其在空 store 上运行,无需缓存未命中,因此不必访问 cache.nixos.org。我遇到了麻烦,因为 Nix 似乎下载了一堆额外的引导内容,显然是为了帮助获取。

例如,考虑此派生:

# empty_store_test_simple.nix
with { inherit (import <nixpkgs> {}) fetchFromGitHub; };

(fetchFromGitHub {
  owner = "codedownio";
  repo = "templates";
  rev = "ba68b83d25d2b74f5475521ac00de3bbb884c983";
  sha256 = "sha256-LNTi1ZBEsThmGWK53U9Na1j5DKHljcS42/PRXj97p6s=";
})

如果我在空 store 上使用 --dry-run 构建它,我会看到以下内容:

λ nix build --impure --store ~/experimental-store --substituters https://cache.nixos.org/ --dry-run -f ./empty_store_test_simple.nix
this derivation will be built:
  /nix/store/jr55kq3kk6va95rvjcdyn5jmh059007p-source.drv
these 48 paths will be fetched (24.52 MiB download, 121.41 MiB unpacked):
  /nix/store/02bfycjg1607gpcnsg8l13lc45qa8qj3-libssh2-1.10.0
  /nix/store/0fi0432kdh46x9kbngnmz2y7z0q68cdz-xz-5.2.5-bin
  /nix/store/0rizskpri8d8qawx6qjqcnvlxcvzr1bm-keyutils-1.6.3-lib
  /nix/store/1l4r0r4ab3v3a3ppir4jwiah3icalk9d-zlib-1.2.11
  /nix/store/1xyz8jwyg9rya2f7gs549c7n2ah378v6-stdenv-linux
  /nix/store/3h4a92kysiw3s3rvbsa6a2nys3lf8f8v-libkrb5-1.18
  /nix/store/3ibnw61rlgj2lj5hycy2dn3ybpq7wapm-libev-4.33
  /nix/store/5qbrz5fimkbywws73vaim8allyh8kjy5-nghttp2-1.43.0-bin
  /nix/store/67x6kxbanrqafx3hg7pb3bc83i3d1v3f-gzip-1.11
  /nix/store/6irxz4fbf1d1ac7wvdjf8cqb3sgmnvg8-zlib-1.2.11-dev
  /nix/store/71pachqc22wlvf3xjhwjh2rqbl6l3ngg-diffutils-3.8
  /nix/store/9mp06ni69a44dmrjhn28mn15brdry52w-gnused-4.8
  /nix/store/9ppi191zsi7zvynkm8vy2bi22lci9iwg-bzip2-1.0.6.0.2
  /nix/store/c9f15p1kwm0mw5p13wsnvd1ixrhbhb12-gcc-10.3.0-lib
  /nix/store/d1n274a607fmqdgr7888nq19hdsj7av0-openssl-1.1.1l-bin
  /nix/store/d8p27w4d21xs6svkaf3ij60lsw243rn2-openssl-1.1.1l-dev
  /nix/store/fdbwa5jrijn0yzwl8l4xdxa0l5daf5j6-curl-7.79.1
  /nix/store/fvprxgcxf4px865gdjd81fbwnxcjrg41-coreutils-9.0
  /nix/store/gf6j3k1flnhayvpnwnhikkg0s5dxrn1i-openssl-1.1.1l
  /nix/store/gmnh4jfjhx83aggwgwzcnrwmpmqr8fwf-gnutar-1.34
  /nix/store/gmzhclix3kzhir5jmmwakwhpg6j5zwf1-acl-2.3.1
  /nix/store/h0b8ajwz9lvw3a3vqrf41cxrhlx9dz7p-nghttp2-1.43.0-lib
  /nix/store/h7srws2r1nalsih91lrm0hfhhar14jzm-libkrb5-1.18-dev
  /nix/store/h97sr1q1rpv1ry83031q51jbkba7q0m4-bzip2-1.0.6.0.2-bin
  /nix/store/ihscadskdrvwc9dvbirff51lr70cphjj-curl-7.79.1-bin
  /nix/store/ikvp5db9hygc14da45lvxi1c9b4ylna9-pcre-8.44
  /nix/store/ilszk5f0zcv8lifkixg47ja1f2lsgxkd-nghttp2-1.43.0-dev
  /nix/store/k0qa3rjifblr2vrgx4g54a59zxlfhg90-xz-5.2.5
  /nix/store/kd14wd2wfmb56zpv5y71yq2lqs11l06k-attr-2.5.1
  /nix/store/ksqy6mszsld4z3w8ybxa2vkjf5cqxw3f-c-ares-1.17.2
  /nix/store/l0wlqpbsvh1pgvhcdhw7qkka3d31si7k-bash-5.1-p8
  /nix/store/lhambyc1v2c7qzzr5sq7p449xs1j6pg8-gnugrep-3.7
  /nix/store/lypy3bif

<details>
<summary>英文:</summary>

I&#39;m trying to set up a Nix cache containing all the store paths needed to build a simple derivation. The goal is for this to work on an empty store, with no cache misses so I don&#39;t have to hit cache.nixos.org at all. I&#39;m having trouble because Nix seems to download a bunch of extra bootstrapping stuff, apparently to help with fetching. 

For example, consider this derivation:

```nix
# empty_store_test_simple.nix
with { inherit (import &lt;nixpkgs&gt; {}) fetchFromGitHub; };

(fetchFromGitHub {
  owner = &quot;codedownio&quot;;
  repo = &quot;templates&quot;;
  rev = &quot;ba68b83d25d2b74f5475521ac00de3bbb884c983&quot;;
  sha256 = &quot;sha256-LNTi1ZBEsThmGWK53U9Na1j5DKHljcS42/PRXj97p6s=&quot;;
})

If I build this on an empty store with --dry-run, I see the following:

λ nix build --impure --store ~/experimental-store --substituters https://cache.nixos.org/ --dry-run -f ./empty_store_test_simple.nix
this derivation will be built:
  /nix/store/jr55kq3kk6va95rvjcdyn5jmh059007p-source.drv
these 48 paths will be fetched (24.52 MiB download, 121.41 MiB unpacked):
  /nix/store/02bfycjg1607gpcnsg8l13lc45qa8qj3-libssh2-1.10.0
  /nix/store/0fi0432kdh46x9kbngnmz2y7z0q68cdz-xz-5.2.5-bin
  /nix/store/0rizskpri8d8qawx6qjqcnvlxcvzr1bm-keyutils-1.6.3-lib
  /nix/store/1l4r0r4ab3v3a3ppir4jwiah3icalk9d-zlib-1.2.11
  /nix/store/1xyz8jwyg9rya2f7gs549c7n2ah378v6-stdenv-linux
  /nix/store/3h4a92kysiw3s3rvbsa6a2nys3lf8f8v-libkrb5-1.18
  /nix/store/3ibnw61rlgj2lj5hycy2dn3ybpq7wapm-libev-4.33
  /nix/store/5qbrz5fimkbywws73vaim8allyh8kjy5-nghttp2-1.43.0-bin
  /nix/store/67x6kxbanrqafx3hg7pb3bc83i3d1v3f-gzip-1.11
  /nix/store/6irxz4fbf1d1ac7wvdjf8cqb3sgmnvg8-zlib-1.2.11-dev
  /nix/store/71pachqc22wlvf3xjhwjh2rqbl6l3ngg-diffutils-3.8
  /nix/store/9mp06ni69a44dmrjhn28mn15brdry52w-gnused-4.8
  /nix/store/9ppi191zsi7zvynkm8vy2bi22lci9iwg-bzip2-1.0.6.0.2
  /nix/store/c9f15p1kwm0mw5p13wsnvd1ixrhbhb12-gcc-10.3.0-lib
  /nix/store/d1n274a607fmqdgr7888nq19hdsj7av0-openssl-1.1.1l-bin
  /nix/store/d8p27w4d21xs6svkaf3ij60lsw243rn2-openssl-1.1.1l-dev
  /nix/store/fdbwa5jrijn0yzwl8l4xdxa0l5daf5j6-curl-7.79.1
  /nix/store/fvprxgcxf4px865gdjd81fbwnxcjrg41-coreutils-9.0
  /nix/store/gf6j3k1flnhayvpnwnhikkg0s5dxrn1i-openssl-1.1.1l
  /nix/store/gmnh4jfjhx83aggwgwzcnrwmpmqr8fwf-gnutar-1.34
  /nix/store/gmzhclix3kzhir5jmmwakwhpg6j5zwf1-acl-2.3.1
  /nix/store/h0b8ajwz9lvw3a3vqrf41cxrhlx9dz7p-nghttp2-1.43.0-lib
  /nix/store/h7srws2r1nalsih91lrm0hfhhar14jzm-libkrb5-1.18-dev
  /nix/store/h97sr1q1rpv1ry83031q51jbkba7q0m4-bzip2-1.0.6.0.2-bin
  /nix/store/ihscadskdrvwc9dvbirff51lr70cphjj-curl-7.79.1-bin
  /nix/store/ikvp5db9hygc14da45lvxi1c9b4ylna9-pcre-8.44
  /nix/store/ilszk5f0zcv8lifkixg47ja1f2lsgxkd-nghttp2-1.43.0-dev
  /nix/store/k0qa3rjifblr2vrgx4g54a59zxlfhg90-xz-5.2.5
  /nix/store/kd14wd2wfmb56zpv5y71yq2lqs11l06k-attr-2.5.1
  /nix/store/ksqy6mszsld4z3w8ybxa2vkjf5cqxw3f-c-ares-1.17.2
  /nix/store/l0wlqpbsvh1pgvhcdhw7qkka3d31si7k-bash-5.1-p8
  /nix/store/lhambyc1v2c7qzzr5sq7p449xs1j6pg8-gnugrep-3.7
  /nix/store/lypy3bif096j0qc1divwa87gdvv3r575-curl-7.79.1-dev
  /nix/store/p12km8psjlmvbmi52wb9r6gfykqxcdnd-libssh2-1.10.0-dev
  /nix/store/pkpynsyxm8c38z4m8ngv52c7v8vhkr2h-unzip-6.0
  /nix/store/prq96vz3ywk955nnxlr7s892wf5qvbr0-mirrors-list
  /nix/store/psqacrv7k5fxz6mdiawc28sxcdchb4c9-ed-1.17
  /nix/store/qbdsd82q5fyr0v31cvfxda0n0h7jh03g-libunistring-0.9.10
  /nix/store/qzr7r4w5gm5m20afn2wz4vlv7ah4sr89-gnumake-4.3
  /nix/store/r5niwjr8r8qags2bzv9z583r9vajxag3-patchelf-0.13
  /nix/store/rnx655nq2qs53yb5arv2gapa91r1wsbn-findutils-4.8.0
  /nix/store/scz4zbxirykss3hh5iahgl39wk9wpaps-libidn2-2.3.2
  /nix/store/sqn31ly001033hsz0dpxwcsay5qdbk2w-gawk-5.1.1
  /nix/store/vslsa0l17xjcrdgm2knwj0z5hlvf73m7-perl-5.34.0
  /nix/store/x6pz7c0ffcd6kxzc8m1rflvqmdbjiihh-nghttp2-1.43.0
  /nix/store/yj11v0gdjqli4nzax4x48xjnh9y36b2q-curl-7.79.1-man
  /nix/store/z56jcx3j1gfyk4sv7g8iaan0ssbdkhz1-glibc-2.33-56
  /nix/store/zjm4xv4nr872mdhvv3j22bzb08rgf1hk-patch-2.7.6

However, I can't find all these paths by using the means I would expect:

λ nix repl empty_store_test_simple.nix
nix-repl&gt; :b with import &lt;nixpkgs&gt; {}; closureInfo { rootPaths = [inputDerivation]; } 

This derivation produced the following outputs:
  out -&gt; /nix/store/1iqm7sr2rr6i5njnfxlqqyzi567mb4cz-closure-info
λ cat /nix/store/1iqm7sr2rr6i5njnfxlqqyzi567mb4cz-closure-info/store-paths
/nix/store/icvdinlsgl6y2kxk9wzkj82a53jgpdlm-source

I would expect to see ~48 paths here, but I only see 1! How can I get all the build-time dependencies indicated by the dry run? I've seen this kind of issue in the past when IFD is present, could there be some going on in Nixpkgs?

答案1

得分: 1

If you build your derivation and store it in your own Nix cache that should work; Nix shouldn't need to get the build-time dependencies of that thing, it can just download the result (i.e. the source code you're fetching) from your cache.

If you want to get the build-time dependencies anyway, try:

nix-store -qR $(nix-instantiate test.nix)

I think this will get you one step closer but it's not a complete solution. You'd probably need to build all the derivations in this list or something.

英文:

If you build your derivation and store it in your own Nix cache that should work; Nix shouldn't need to get the build-time dependencies of that thing, it can just download the result (i.e. the source code you're fetching) from your cache.

If you want to get the build-time dependencies anyway, try:

nix-store -qR $(nix-instantiate test.nix)

I think this will get you one step closer but it's not a complete solution. You'd probably need to build all the derivations in this list or something.

huangapple
  • 本文由 发表于 2023年2月18日 13:01:35
  • 转载请务必保留本文链接:https://go.coder-hub.com/75491301.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定