Using URLs and SWHIDs directly in “guix pull” and “guix time-machine”
Today I stumbled upon a recently published (one month ago) blog post by the Guix team: Time travel without borders. It was a worthwhile read.
guix time-machine is used to go back or forward in time (relative to the current Guix profile) and call other Guix subcommands. For instance, to run the yt-dlp binary from the latest Guix commit:
guix time-machine -q -- shell yt-dlp -- yt-dlp …Another example comes from my personal Guix config: to test if my home environment configuration would build properly if I did a guix pull, I do something like:
guix home reconfigure -L src --expression='(@ (krisb config machines MACHINE home) MACHINE-home-environment)'Both of the above are examples of going “forward” in time (i.e., forward in the Guix repository commit history), but one can just as easily go back to earlier commits.
The article goes over a recently added feature to guix pull and guix time-machine. I believe it comes from this PR:
This new feature basically lets one provide a URL or SWHID (Software Hash Identifiers)[1] to guix pull or guix time-machine directly. (The latter is more secure, since it involves a content hash.)
So, instead of having to do something like the following, where one fetches a file via e.g. wget then calls guix time-machine:
wget -O channels.scm \ https://ci.guix.gnu.org/eval/latest/channels.scm?spec=masterguix time-machine -C channels.scm -- shell …or the one-line Bash equivalent:
guix time-machine \-C <(wget -O https://ci.guix.gnu.org/eval/latest/channels.scm?spec=master) \-- shell …We can do the following instead, using a URL directly:
guix time-machine \-C https://ci.guix.gnu.org/eval/latest/channels.scm?spec=master \-- …or with a SWHID
guix time-machine \-C swh:1:cnt:003e1e0c1b9b358082201332c926ae54e9549002 \-- …Really cool!