Hi all, I've been writing a script that given a date/time and a profile will return the details of that profile at that date/time, including the channels used to create the profile.
Initially I though this would be as easy as: guix pull -p my-profile -l But this seems to crash: ________________________________ blah@phil:~$ guix pull -p my-profile -l \Generation 1 Dec 22 2020 17:24:53\ my-test-repo 1.49-3.f08de71 \Generation 2 Dec 22 2020 17:50:28\ guix 13d532a repository URL: https://git.savannah.gnu.org/git/guix.git branch: master commit: \13d532a91178be7b6919b85685b150f941116dfc\ foo-packages 8fc6134 repository URL: ssh://git@localgit:7999/foo/foo-packages.git branch: master commit: 3dc613449f59ba8a8fdc35cadb7667ddaaf7fd9b Backtrace: 11 (primitive-load "/home/blah/.config/guix/current/bin/…") In guix/ui.scm: 2127:12 10 (run-guix-command _ . _) In ice-9/boot-9.scm: 1736:10 9 (with-exception-handler _ _ #:unwind? _ # _) 1731:15 8 (with-exception-handler #<procedure 7fa030b82b40 at ic…> …) 1731:15 7 (with-exception-handler #<procedure 7fa030b82b10 at ic…> …) 1731:15 6 (with-exception-handler #<procedure 7fa030c46390 at ic…> …) In guix/scripts/pull.scm: 636:4 5 (_) In guix/memoization.scm: 100:0 4 (_ #<hash-table 7fa030b4c780 0/31> "guix-profiles/py-t…" …) In guix/scripts/pull.scm: 538:21 3 (_) In guix/inferior.scm: 256:2 2 (inferior-available-packages #f) 251:13 1 (send-inferior-request (defined? (quote #)) #f) In ice-9/boot-9.scm: 1669:16 0 (raise-exception _ #:continuable? _) ice-9/boot-9.scm:1669:16: In procedure raise-exception: In procedure struct-vtable: Wrong type argument in position 1 (expecting struct): #f blah@phil:~$ ________________________________ This was a bit unexpected as you can call 'guix describe' with a profile (although you only get channel infomation if you leave off the -p switch). So instead I decided to write my own script. I've left how I work out the generation running on a given profile at a given datetime - but this is easy enough to do (look for nearest generation-time less than the provided datetime). Armed with this, the following looked like a good starting place: (display-profile-content my-profile generation-number) With me providing a profile and generation I want details on. There are 2 versions of the display-profile-content function; one in (guix ui) and one in (guix scripts describe). https://github.com/guix-mirror/guix/blob/d482569c2289647e666228cad238552b18f09410/guix/scripts/describe.scm#L232 https://github.com/guix-mirror/guix/blob/d482569c2289647e666228cad238552b18f09410/guix/ui.scm#L1947 The ui.scm version doesn't have the details I want, but the describe.scm one looked promising. However the match sequence in display-profile-content in describe.scm is looking for 'source not 'provenance - which if I look at the manifest under the profile won't match? Also it only seemed to match against the first 'repository - which is no good if a private channel is used by the profile. So whilst display-profile-content correctly displays information from display-generation, the for-each over the manifest entries doesn't yield any url/branch/commit info - at least for what I want to do. I also looked at the profile-channels function but drew a blank there too. The code at describe.scm was close enough that I could fairly easily repurpose it (see below). However my questions are: Os there not already a cannonical way to do this in Guix? If yes, what is it? If no is my approach below sane, or is what I'm trying to achieve ill-conceived in any way? Finally, what's the intended difference between 'source and 'provenance? To my mind - If a profile generation has a manifest which contains branch/commit details of the branches packages were created with - it seems reasonable and useful to report that information? Thanks, Phil. ________________________________ (format #t "~%~%Package/Channel Details:~%") (define my-manifest (manifest-entries (profile-manifest (generation-file-name my-profile generation-number)))) (for-each (lambda (entry) (format #t " ~a ~a~%" (manifest-entry-name entry) (manifest-entry-version entry)) (match (assq 'provenance (manifest-entry-properties entry)) (('provenance ('repository ('version 0) ('url url) ('branch branch) ('commit commit) _ ...) ...) (let ((repo-triples (zip url branch commit))) (map (lambda (triple) (apply format (append (list #t " URL: ~a~% Branch: ~a~% Commit: ~a~%~%") triple))) repo-triples))) (_ #f))) (reverse my-manifest)) ________________________________