Ludovic Courtès writes: > Hello Guix! > > Here’s a client module for the Guix Data Service, allowing you to access > a subset of the Guix Data Service interfaces from the comfort of your > REPL. > > I had it sitting in my source tree for a while and Chris sent me an > impressive shell one-liner that made me want to try from Scheme: > > wget > "https://data.guix-patches.cbaines.net/revision/47f85c53d954f857b45cebefee27ec512d917484/lint-warnings.json?locale=en_US.UTF-8&linter=input-labels&field=linter&field=message&field=location" > -O - | jq -r '.lint_warnings | .[] | .package.name' | sort | uniq | wc > -l > > Turns out we can do the same in two long lines of Scheme! > > scheme@(guix data-service)> (define s (open-data-service "https://data.guix-patches.cbaines.net")) > scheme@(guix data-service)> (length (delete-duplicates (map lint-warning-package (revision-lint-warnings s "47f85c53d954f857b45cebefee27ec512d917484" "input-labels")))) > $6 = 3560 > > > (That counts the number of packages at that revision that have one or > more warnings from the new ‘input-labels’ lint checker.) > > We can do other things, such as browsing package versions: > > scheme@(guix data-service)> (define s (open-data-service "https://data.guix.gnu.org")) > scheme@(guix data-service)> (package-version-branches (car (package-versions (lookup-package s "emacs")))) > $9 = (#< name: "master" repository-id: 1>) > scheme@(guix data-service)> (package-version-history s (car $9) "emacs") > $10 = (#< version: "27.2" first-revision: #< commit: "cc33f50d0e2a7835e99913226cb4c4b0e9e961ae" date: #> last-revision: #< commit: "364b56124b88398c199aacbfd4fdfc9a1583e634" date: #>> #< version: "27.1" first-revision: #< commit: "36a09d185343375a5cba370431870f9c4435d623" date: #> last-revision: #< commit: "ac29d37e2ffd7a85adfcac9be4d5bce018289bec" date: #>> #< version: "26.3" first-revision: #< commit: "43412ab967ee00789fe933f916d804aed9961c57" date: #> last-revision: #< commit: "bf19d5e4b26a2e38fe93a45f9341e14476ea5f82" date: #>> #< version: "26.2" first-revision: #< commit: "5069baedb8a902c3b1ea9656c11471658a1de56b" date: #> last-revision: #< commit: "02c61278f1327d403f072f42e6b92a1dc62fc93a" date: #>> #< version: "26.1" first-revision: #< commit: "897f303d2fa61497a931cf5fcb43349eb5f44c14" date: #> last-revision: #< commit: "ee6c4b62b88640f3828cf73a30377124e16cb95f" date: #>>) > > Now all we need to do is plug it into the right tools and enjoy! Thanks for writing this Ludo, sorry it's taken so long for me to have a look. I've had a little play around with it locally, and it seems to work well. I added some exports (included below) so that I could more easily use the module. Maybe open-data-service could have the url default to "https://data.guix.gnu.org". The only thing I can see that's required before merging though is the exports. I'm now thinking about this kind of thing (getting data out of the data service) in the context of patch/branch review. Thanks, Chris #:export (repository? repository-id repository-label repository-url repository-branches branch? branch-name branch-repository-id package-version? package-version-string package-version-branches package? package-name package-versions revision? revision-commit revision-date build? build-server-id build-id build-time channel-instance? channel-instance-system channel-instance-derivation channel-instance-builds lint-warning? lint-warning-package lint-warning-package-version lint-warning-message lint-warning-location open-data-service lookup-package lookup-repository package-version-history revision-channel-instances revision-lint-warnings))