brianmcgee commited on
Commit
2ba20d7
·
unverified ·
1 Parent(s): 1fead68

doc: update README

Browse files
Files changed (1) hide show
  1. README.md +194 -1
README.md CHANGED
@@ -25,4 +25,197 @@ configs:
25
 
26
  # Nix Cache Dataset
27
 
28
- TBD
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25
 
26
  # Nix Cache Dataset
27
 
28
+ This repository contains several datasets relating to the contents of https://cache.nixos.org:
29
+
30
+ ## Getting started
31
+
32
+ To make it easier to explore the datasets, a [Nix] devshell is provided in `shell.nix`. To enter it, run
33
+
34
+ ```console
35
+ ❯ nix develop -f shell.nix
36
+
37
+ [brian@saturn:~/Development/com/github/numtide/nix-cache-dataset]$
38
+ ```
39
+
40
+ If you are a [Direnv] user, you can also run `direnv allow` to automatically load the devshell:
41
+
42
+ ```console
43
+ ❯ direnv allow
44
+ direnv: loading ~/Development/com/github/numtide/nix-cache-dataset/.envrc
45
+ direnv: using nix
46
+ direnv: nix-direnv: Using cached dev shell
47
+ direnv: export +AR +AS +CC +CONFIG_SHELL +CXX +HOST_PATH +IN_NIX_SHELL +LD +NIX_BINTOOLS +NIX_BINTOOLS_WRAPPER_TARGET_HOST_x86_64_unknown_linux_gnu +NIX_BUILD_CORES +NIX_CC +NIX_CC_WRAPPER_TARGET_HOST_x86_64_unknown_linux_gnu +NIX_CFLAGS_COMPILE +NIX_ENFORCE_NO_NATIVE +NIX_HARDENING_ENABLE +NIX_LDFLAGS +NIX_STORE +NM +OBJCOPY +OBJDUMP +RANLIB +READELF +SIZE +SOURCE_DATE_EPOCH +STRINGS +STRIP +__structuredAttrs +buildInputs +buildPhase +builder +cmakeFlags +configureFlags +depsBuildBuild +depsBuildBuildPropagated +depsBuildTarget +depsBuildTargetPropagated +depsHostHost +depsHostHostPropagated +depsTargetTarget +depsTargetTargetPropagated +doCheck +doInstallCheck +dontAddDisableDepTrack +mesonFlags +name +nativeBuildInputs +out +outputs +patches +phases +preferLocalBuild +propagatedBuildInputs +propagatedNativeBuildInputs +shell +shellHook +stdenv +strictDeps +system ~PATH ~XDG_DATA_DIRS
48
+
49
+ brian@saturn ~/..../nix-cache-dataset  main* ⇡
50
+
51
+ ```
52
+
53
+ The devshell contains a `duckdb` command which is pre-configured to load some helpful utility functions which reside in
54
+ `./duckdb/init.sql`:
55
+
56
+ * `nixbase32` which converts a fixed-size `byte[20]` column into nixbase32
57
+ * `narURL` which recovers the URL of a NAR file from it's `file_hash` and `compression` columns.
58
+
59
+ Both are necessary when introspecting any of the narinfo related datasets as their schema was optimized to reduce file
60
+ sizes.
61
+
62
+ ## Contents
63
+
64
+ > [!NOTE]
65
+ > The primary datasets below were compiled with [Narwal].
66
+
67
+ ### `datasets/inventory-2026-01-06T01-13Z.parquet`
68
+
69
+ This is a complete inventory of the [S3 Bucket] which backs the cache as of `2026-01-06T01:13Z` and provided by the
70
+ [S3 Inventory Service]. It has the following schema and is ordered by `key`:
71
+
72
+ ```console
73
+ ❯ duckdb -c "describe select * from 'datasets/inventory-2026-01-06T01-13Z.parquet'"
74
+ ┌────────────────────┬──────────────────────────┬─────────┬─────────┬─────────┬─────────┐
75
+ │ column_name │ column_type │ null │ key │ default │ extra │
76
+ │ varchar │ varchar │ varchar │ varchar │ varchar │ varchar │
77
+ ├────────────────────┼──────────────────────────┼─────────┼─────────┼─────────┼─────────┤
78
+ │ key │ VARCHAR │ YES │ NULL │ NULL │ NULL │
79
+ │ size │ BIGINT │ YES │ NULL │ NULL │ NULL │
80
+ │ last_modified_date │ TIMESTAMP WITH TIME ZONE │ YES │ NULL │ NULL │ NULL │
81
+ │ e_tag │ VARCHAR │ YES │ NULL │ NULL │ NULL │
82
+ │ storage_class │ VARCHAR │ YES │ NULL │ NULL │ NULL │
83
+ └────────────────────┴──────────────────────────┴─────────┴─────────┴─────────┴─────────┘
84
+ ```
85
+
86
+ Here is the first 10 entries:
87
+
88
+ ```console
89
+ ❯ duckdb -c "select * from 'datasets/inventory-2026-01-06T01-13Z.parquet' limit 10"
90
+ ┌──────────────────────────────────────────┬───────┬──────────────────────────┬──────────────────────────────────┬───────────────┐
91
+ │ key │ size │ last_modified_date │ e_tag │ storage_class │
92
+ │ varchar │ int64 │ timestamp with time zone │ varchar │ varchar │
93
+ ├──────────────────────────────────────────┼───────┼──────────────────────────┼──────────────────────────────────┼───────────────┤
94
+ │ .well-known/pki-validation/gsdv.txt │ 101 │ 2018-09-07 09:35:54+01 │ dcdfef6f1cdfeae2d2c9de7dab84292a │ STANDARD │
95
+ │ 000003nzgismzlipaq0jnchpz65d65z7.ls │ 1228 │ 2024-06-21 17:17:36+01 │ bf47b9ab2ea7a795d15107d4dcf64697 │ STANDARD │
96
+ │ 000003nzgismzlipaq0jnchpz65d65z7.narinfo │ 1452 │ 2024-06-21 17:17:37+01 │ 34997acded08172170eb1a4cde9456d1 │ STANDARD │
97
+ │ 00000c8rdrjqkdxjpm5wrhl6sspapbmn.ls │ 97 │ 2019-11-06 19:35:06+00 │ ae368bafcfb9e5632acc57acf4f2a325 │ STANDARD │
98
+ │ 00000c8rdrjqkdxjpm5wrhl6sspapbmn.narinfo │ 905 │ 2019-11-06 19:35:06+00 │ 0bf1c5c76cf15dd07c8c79eca27ebff4 │ STANDARD │
99
+ │ 00000in9ndrbpshcibwfgsygx0xq069g.ls │ 329 │ 2025-11-07 18:40:26+00 │ f817f1b476fe0cb82ac2f5dbc19be620 │ STANDARD │
100
+ │ 00000in9ndrbpshcibwfgsygx0xq069g.narinfo │ 732 │ 2025-11-07 18:40:28+00 │ 4037fbf8ab5484847756f0839c2c7245 │ STANDARD │
101
+ │ 00000jipsrr2nfgn36w04xg2z6hnr7y0.ls │ 323 │ 2024-01-06 07:48:26+00 │ 8a3bad8cb3795080ccd636ef212c1878 │ STANDARD │
102
+ │ 00000jipsrr2nfgn36w04xg2z6hnr7y0.narinfo │ 523 │ 2024-01-06 07:48:27+00 │ 997c5c9a6911bfadd7efcb9f845a4082 │ STANDARD │
103
+ │ 00000lkv8yz6bsccrp03ppq71mzjdcpv.ls │ 396 │ 2022-05-10 03:33:54+01 │ 3284e9e9e5ae0a2562640e1f20af395d │ STANDARD │
104
+ ├──────────────────────────────────────────┴───────┴──────────────────────────┴──────────────────────────────────┴───────────────┤
105
+ │ 10 rows 5 columns │
106
+ └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────���────────┘
107
+ ```
108
+
109
+ ### `datasets/narinfos-2026-01-06T01-13Z.parquet``
110
+
111
+ This is a complete download of all `.narinfo` files within the S3 bucket as of `2026-01-06T01:13Z`. It has the following
112
+ schema:
113
+
114
+ ```console
115
+ ❯ duckdb -c "describe select * from 'datasets/narinfos-2026-01-06T01-13Z.parquet'
116
+ ┌───────────────────────────────┬─────────────┬─────────┬─────────┬─────────┬─────────┐
117
+ │ column_name │ column_type │ null │ key │ default │ extra │
118
+ │ varchar │ varchar │ varchar │ varchar │ varchar │ varchar │
119
+ ├───────────────────────────────┼─────────────┼─────────┼─────────┼─────────┼─────────┤
120
+ │ hash │ BLOB │ YES │ NULL │ NULL │ NULL │
121
+ │ pname │ VARCHAR │ YES │ NULL │ NULL │ NULL │
122
+ │ compression │ VARCHAR │ YES │ NULL │ NULL │ NULL │
123
+ │ file_hash │ BLOB │ YES │ NULL │ NULL │ NULL │
124
+ │ file_size │ UBIGINT │ YES │ NULL │ NULL │ NULL │
125
+ │ nar_hash │ BLOB │ YES │ NULL │ NULL │ NULL │
126
+ │ nar_size │ UBIGINT │ YES │ NULL │ NULL │ NULL │
127
+ │ references │ BLOB[] │ YES │ NULL │ NULL │ NULL │
128
+ │ deriver │ BLOB │ YES │ NULL │ NULL │ NULL │
129
+ │ deriver_pname │ VARCHAR │ YES │ NULL │ NULL │ NULL │
130
+ │ system │ VARCHAR │ YES │ NULL │ NULL │ NULL │
131
+ │ signature_domains │ VARCHAR[] │ YES │ NULL │ NULL │ NULL │
132
+ │ signature_values │ BLOB[] │ YES │ NULL │ NULL │ NULL │
133
+ │ ca_algo │ VARCHAR │ YES │ NULL │ NULL │ NULL │
134
+ │ ca_hash │ BLOB │ YES │ NULL │ NULL │ NULL │
135
+ │ quirk_references_out_of_order │ BOOLEAN │ YES │ NULL │ NULL │ NULL │
136
+ ├───────────────────────────────┴─────────────┴─────────┴─────────┴─────────┴─────────┤
137
+ │ 16 rows 6 columns │
138
+ └─────────────────────────────────────────────────────────────────────────────────────┘
139
+ ```
140
+
141
+ The schema is the same as the contents of a `.narinfo` file with some notable differences:
142
+
143
+ * `StorePath` has been split into `hash` and `pname`, with the `/nix/store/` prefix omitted.
144
+ * In addition, `hash` has been decoded from its original 32-byte `nixbase32` format into a 20-byte fixed-size `byte[20]`
145
+ column to save space. As mentioned in [Getting Started](#Getting-started), there is a `nixbase32` utility function for
146
+ `duckdb` which can be used to convert it back into it's original format.
147
+ * `URL` is not included. Instead, it can be recovered from the `file_hash` and `compression` columns using the `narURL`
148
+ utility function. Again, this was to save space.
149
+ * `quirk_references_out_of_order` indicates whether the `references` column was not canonically sorted as is required by
150
+ the narinfo format.
151
+
152
+ Here is an example of using both:
153
+
154
+ ```console
155
+ ❯ duckdb -c " select nixbase32(hash) as hash, pname, narURL(file_hash, compression) as URL from 'datasets/narinfos-2026-01-06T01-13Z.parquet' where pname like 'nixos-%.iso' limit 10"
156
+ ┌──────────────────────────────────┬──────────────────────────────────────────────────────────────────────┬─────────────────────────────────────────────────────────────────┐
157
+ │ hash │ pname │ URL │
158
+ │ varchar │ varchar │ varchar │
159
+ ├──────────────────────────────────┼──────────────────────────────────────────────────────────────────────┼─────────────────────────────────────────────────────────────────┤
160
+ │ 8s2i888nxl44dvrqkszyhm9wagx21cv8 │ nixos-21.11pre-git-aarch64-linux.iso │ nar/01i2cax5rgfirdnqy3gk0fam1jxjqzydlm6fmydqcr2rppzfgpyc.nar.xz │
161
+ │ 8s2nl0q5l0qjwj4mdh47b32abd7dkb37 │ nixos-plasma5-23.11pre525972.ace5093e36ab-x86_64-linux.iso │ nar/03wiqhgkgbwr6lz6jlhnq9d4swjahdw32ylixshmpy25wmnhkg83.nar.xz │
162
+ │ 8s308z464is6rbnn1wglws37bz5cxhi3 │ nixos-minimal-new-kernel-21.03pre253346.87e9b49fc78-x86_64-linux.iso │ nar/1ppngdicfkydg44hbyc6s77f40qk15a8r370a02yg06y4w7fscp3.nar.xz │
163
+ │ 8s37vnmdg68z51s81lp7pfclkp0ljl7v │ nixos-plasma5-21.11.335288.3ddd960a3b5-x86_64-linux.iso │ nar/04pic41qkjib69bl1yk48w5bdnb0jj4jfzljmfxsx3c9sr966m71.nar.xz │
164
+ │ 8s4yq0kgvw7d34jzd6j256n8rhqdncag │ nixos-18.03pre-git-x86_64-linux.iso │ nar/11m49i89vpm8mjq2khpiy9p4br3fkvk57nmi6narmxbih9lahg45.nar.xz │
165
+ │ 8s4zyq65nl0d5jjd28pvm8rih78khhlx │ nixos-21.03pre-git-x86_64-linux.iso │ nar/00ivaz2lwdvqcg7c64l9ikgk0njcphad4h69z2hvih7xrrzvwbb0.nar.xz │
166
+ │ 8s5577gfk2makszs3bnpfzf8h477ywwd │ nixos-minimal-17.03.1730.dad3c2231c-i686-linux.iso │ nar/074d9323apli87919s8rr8rfa0javdqvk24r4siclq1ysg67gp38.nar.xz │
167
+ │ 8s580im104kqdf873sc1bqanp5x7mvjn │ nixos-18.09pre-git-x86_64-linux.iso │ nar/0nw2zmxw3bhn9ixx66n9vfhk81qvr88yh1a3dxyv1qi5xbqv8fgz.nar.xz │
168
+ │ 8s5wj1h8hcvhiqxghlgblxnsi8lccrs7 │ nixos-graphical-25.11pre819493.4206c4cb5675-x86_64-linux.iso │ nar/0mnwc0lpxf4hllv97gc58rd7m0rkph03cg2b35zmarq1kcd1ihq5.nar.xz │
169
+ │ 8s616arfxnpgz8grd3rggm9ahgk5wvn7 │ nixos-minimal-19.09pre174421.b306b4cf1a9-x86_64-linux.iso │ nar/1qxcksrfa9nv10ln5kf2mcx2jndx4hyf34x594779f0lh4rlfw68.nar.xz │
170
+ ├──────────────────────────────────┴──────────────────────────────────────────────────────────────────────┴─────────────────────────────────────────────────────────────────┤
171
+ │ 10 rows 3 columns │
172
+ └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
173
+ ```
174
+
175
+ ### `datasets/narinfos-nixos-2026-01-06T01-13Z.parquet`
176
+
177
+ This is a subset of the `narinfos-2026-01-06T01-13Z.parquet` dataset which is attempting to identify any narinfos related
178
+ to NixOS ISOs and other images which have been uploaded to the cache. These are candidates for removal from the cache as
179
+ they are stored elsewhere.
180
+
181
+ It was compiled using `./duckdb/nixos-images.sql`;
182
+
183
+ ### `datasets/buildstepoutputs-2025-12-05-17:38:30Z.csv.zst`
184
+
185
+ This is a dump of the `buildstepoutputs` table taken from [Hydra] on `2025-12-05T17:38:30Z`. It can be thought of as a
186
+ record of every output path that [Hydra] has ever built and looks like this:
187
+
188
+ ```console
189
+ ❯ head datasets/buildstepoutputs-2025-12-05-17:38:30Z.csv
190
+ build,stepnr,name,path
191
+ 684,2,out,/nix/store/mnkbj3aziazk2ijadn23cpwarm6bfmh8-nixos-install
192
+ 683,5,out,/nix/store/172yppi4bklbs1cyh91wqwpyyfbkvgds-system-path
193
+ 684,3,out,/nix/store/dxi8ij2la8in64mclyjslgs04nylcsa2-upstart-manual
194
+ 685,1,out,/nix/store/isaw8s240isvg06pimbr1wj12wxs9glv-hydra-build
195
+ 684,4,out,/nix/store/qcpb0179capgcyij03xk6fqhlwbafjr0-upstart-jobs
196
+ 686,1,out,/nix/store/07syvqz4w8n0z3alfm4kg5i46v3wbidx-checkinstall-1.6.1
197
+ 686,2,out,/nix/store/1g5nks931nirya16hmw2l1lg0jwazmsw-e2fslibs_1.39+1.40-WIP-2006.11.14+dfsg-2etch1_amd64.deb
198
+ 686,3,out,/nix/store/0dgvq0q33sniq77kq9150shj0jqllzh0-file_4.17-5etch3_amd64.deb
199
+ 686,4,out,/nix/store/7f03xxka0l0h623ydvqsjvqf6w1vvhzv-heimdal-1.0.2.tar.gz
200
+ ```
201
+
202
+ ### `datasets/inventory-not-in-buildstepoutputs-2025-12-05-17:38:30Z.parquet`
203
+
204
+ This file contains a list of all the `.narinfo` files within `datasets/inventory-2026-01-06T01-13Z.parquet`
205
+ (up to `2025-12-05-17:38:30Z`) which do not have a corresponding entry in
206
+ `datasets/buildstepoutputs-2025-12-05-17:38:30Z.csv.zst`.
207
+
208
+ It was compiled using `./duckdb/inventory-not-in-buildstepoutputs.sql`;
209
+
210
+ Subsequently, graphs were generated using `bin/graph-inventory-not-in-buildstepoutputs.py` and placed in `./graphs`:
211
+
212
+ ![Inventory not in Buildstepoutputs Daily](./graphs/inventory-not-in-buildstepoutputs-daily.png)
213
+ ![Inventory not in Buildstepoutputs Monthly](./graphs/inventory-not-in-buildstepoutputs-monthly.png)
214
+ ![Inventory not in Buildstepoutputs Daily](./graphs/inventory-not-in-buildstepoutputs-yearly-comparison.png)
215
+
216
+ [Nix]: https://nixos.org/
217
+ [Direnv]: https://direnv.net/
218
+ [S3 Bucket]: https://aws.amazon.com/s3/
219
+ [S3 Inventory Service]: https://docs.aws.amazon.com/AmazonS3/latest/dev/storage-inventory.html
220
+ [Narwal]: https://github.com/numtide/narwal
221
+ [Hydra]: https://hydra.nixos.org/