How can I find build information of a particular guix store item

120 Views Asked by At

After messing around with the GNU Guix system for a while, I end up with several "guile-3.0.9/" directory in my /gnu/store/

ls -p /gnu/store | grep 'guile-3.0.9/'
10p9mh0h11z2gs2z72lqnxq96ln6a5x7-guile-3.0.9/
4gvgcfdiz67wv04ihqfa8pqwzsb0qpv5-guile-3.0.9/
84rvhd3j7pfqrh7717cv7ddv2dc8xad5-guile-3.0.9/
g8p09w6r78hhkl2rv1747pcp9zbk6fxv-guile-3.0.9/
rabsjkkm22xhz1vr5dh7r4ai98zprywx-guile-3.0.9/
sg2csvgqqc8r6519pyaqk6c4l1plh40f-guile-3.0.9/

Since their base32 hash prefix are different, I guess they have different input when being built. I really want to know some particular information about those packages, like:

  • when they were built,
  • which one is newer,
  • what are their build input,
  • why they are in my store directory, etc.

Since I always use the substitute servers, I try to get the information from the "ci.guix.gnu.org" website. I actually find the build output of https://ci.guix.gnu.org/build/2076542/details is "4gvgcfdiz67wv04ihqfa8pqwzsb0qpv5-guile-3.0.9". But I am not lucky for other items. It is very hard to find a particular store item from the CI website.

So my question is: if I have one gnu store item, how and where can I get associated information of it?

PS. I know some of the packages are just dead items, and will be garbage collected when I run guix gc.

1

There are 1 best solutions below

0
On

So my question is: if I have one gnu store item, how and where can I get associated information of it?

Most of the available information can be derived from the .drv files corresponding to a store item.

Since their base32 hash prefix are different, I guess they have different input when being built.

Correct, the hash prefix of a guix store item is derrived from the inputs to the derivation; so if those change, the prefix changes as well.

which one is newer,

While the mtime timestamp of store items is set to 1 (00:00:01 1/1/1970 UTC), you could use e.g. ctime or the birth timestamp of a store item to determine it's age in most cases (assuming that these have been reliably set in this case):

(~) λ stat /gnu/store/x4m56h5qkim0pnvx6vgvp541mrdwdrah-guile-3.0.9/
  File: /gnu/store/x4m56h5qkim0pnvx6vgvp541mrdwdrah-guile-3.0.9/
  Size: 4096        Blocks: 8          IO Block: 4096   directory
Device: 253,0   Inode: 5149742     Links: 7
Access: (0555/dr-xr-xr-x)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2024-01-21 03:04:50.000000000 +0100
Modify: 1970-01-01 01:00:01.000000000 +0100
Change: 2024-01-21 03:04:53.536941139 +0100
Birth: 2024-01-21 03:04:50.508934846 +0100

what are their build input,

For this to know you'll need to inspect the corresponding .drv file of a store item. If we want to look at the build inputs of the store item /gnu/store/x4m56h5qkim0pnvx6vgvp541mrdwdrah-guile-3.0.9/ we could locate the corresponding .drv file:

(~) λ grep -l 'x4m56h5qkim0pnvx6vgvp541mrdwdrah' /gnu/store/*guile*drv
/gnu/store/viypkfsq294qmhdakwcmjij3586yb8z6-guile-3.0.9.drv

and then open it in e.g. a text editor or simply print it to STDOUT to inspect it. The .drv files in Guix use the ATerm format (see Chapter 1. The ATerm Programming Guide for further information on the format in particular).

If you want to compare store items or pretty-print their inputs for better readability, you could use the (guix derivations) guile modules for this.

There's read-derivation-from-file to read a .drv file into a guile record (Records (Guile Reference Manual)); then the contents of the .drv file (or parts of it, e.g. derivation-inputs if you only want to work with the inputs), can be pretty-printed:

(use-modules (guix derivations)
             (guix store)
             (ice-9 pretty-print))

(let ((mydrv (read-derivation-from-file "/gnu/store/viypkfsq294qmhdakwcmjij3586yb8z6-guile-3.0.9.drv")))
  (pretty-print (derivation-inputs mydrv)))

like this:

(~/devel/store-diff)) λ guile inspect-derivation.scm | head -n 5
(#<<derivation-input> drv: #<derivation /gnu/store/3cbzvhhamvz491dh4j6nnj2y9rkqlnmm-libunistring-1.0.drv => /gnu/store/0jk7sl5xqwwdkzjpp9sxgz9z0d48a3vy-libunistring-1.0 /gnu/store/6x16x1030b7b4v9vz2fbr3v0fc5gni8g-libunistring-1.0-static 7fc2c8684e60> sub-derivations: ("out")>
 #<<derivation-input> drv: #<derivation /gnu/store/6d15kljmay1q3dc3aaf58wfp6qkns3zf-pkg-config-0.29.2.drv => /gnu/store/jz5dwdxq4di29cd0rjjzkw356dhkzjil-pkg-config-0.29.2 7fc2c8637a00> sub-derivations: ("out")>
 #<<derivation-input> drv: #<derivation /gnu/store/6iigxjcxl3har0w2pl3rqw4dsh6vqjmq-libffi-3.4.4.drv => /gnu/store/d7mbw8ga6nxg7bxcxsfhfh6fraj6i3bz-libffi-3.4.4-debug /gnu/store/w8b0l8hk6g0fahj4fvmc4qqm3cvaxnmv-libffi-3.4.4 7fc2c86495a0> sub-derivations: ("out")>
 #<<derivation-input> drv: #<derivation /gnu/store/95ni9azjf87ypa9rcaarbx1hqsj2vmb7-libgc-8.2.2.drv => /gnu/store/hf00yhc42r93sfbpvcpxrl9i0flgk0rq-libgc-8.2.2-debug /gnu/store/1w1r6r56z9lhg8ghcb7lxss6mkn7d5l1-libgc-8.2.2 7fc2c86379b0> sub-derivations: ("out")>
 #<<derivation-input> drv: #<derivation /gnu/store/cr1r72cbww33k2fzd4wwj83cnw1r3igw-glibc-2.35.drv => /gnu/store/0lzva77yj6hddmhasia65krknyi8kxsg-glibc-2.35-debug /gnu/store/gsjczqir1wbz8p770zndrpw4rnppmxi3-glibc-2.35 /gnu/store/l0yryi5jsa1grnvw01c9nkz9c81cv224-glibc-2.35-static 7fc2c8649fa0> sub-derivations: ("out")>

to get the difference in inputs of two derivations you could utilize lset-difference (srfi-1) on the build-inputs of two derivations:

(use-modules (guix derivations)
        (srfi srfi-1)
             (ice-9 pretty-print))

(let ((adrv (read-derivation-from-file "/gnu/store/viypkfsq294qmhdakwcmjij3586yb8z6-guile-3.0.9.drv"))
      (bdrv (read-derivation-from-file "/gnu/store/5svli5h2zfdyvx1cj65l02nqggnrdahx-guile-3.0.9.drv")))
  (pretty-print (lset-difference eqv?
                  (derivation-inputs adrv) 
                  (derivation-inputs bdrv))))

why they are in my store directory, etc.

This is something you can inspect with guix graph (passing -t referrers or -t references) or guix gc (passing --references or --referrers). You could graph the output of guix graph with xdot to inspect the relationships of your store item with other store items: guix graph -t referrers /gnu/store/1gd9nsy4cps8fnrd1avkc9l01l7ywiai-guile-3.0.9 | guix shell xdot -- xdot - to get a better idea of why they're in your store/which other package pulled them in as a dependency and so on.