GNU bug report logs -
#50515
(guix-artwork)[PATCH 0/2] List linux origins in 'sources.json'.
Previous Next
Reported by: zimoun <zimon.toutoune <at> gmail.com>
Date: Sat, 11 Sep 2021 00:15:02 UTC
Severity: normal
Tags: patch
Done: Ludovic Courtès <ludo <at> gnu.org>
Bug is archived. No further changes may be made.
Full log
Message #41 received at 50515 <at> debbugs.gnu.org (full text, mbox):
Hi!
zimoun <zimon.toutoune <at> gmail.com> skribis:
> With Guix 9875f9bca3976bf3576eab9be42164fde454597e, the packages considered
> are IceCat and the Linux kernel; see: gnu/packages/gnuzilla.scm and
> gnu/packages/linux.scm.
>
> * website/apps/packages/builder.scm (gexp-references): Unexported procedure
> from the module '(guix gexp)'.
> (origin->json): Add 'computed-origin-method' case.
> (package-json-builder): Adjust.
> (sources-json-builder): Idem.
> [flatten]: New procedure.
Apologies for the looong delay!
> +;;; Required by 'origin->json' for 'computed-origin-method' corner cases
> +(define gexp-references (@@ (guix gexp) gexp-references))
Hmm not great. The only public API that would allow us to approximate
it is ‘lower-gexp’, but it requires access to the daemon, so it’s not
suitable.
Let’s keep it this way!
> (define (package->json package)
> `(,@(if (origin? (package-source package))
> (origin->json (package-source package))
> - `(("type" . "no-origin")
> + `((type . "no-origin")
> ("name" . ,(package-name package))))))
>
> + (define (flatten lst)
> + ;; Convert nested lists to simple list
> + `(,@(if (null? lst)
> + '()
> + (match lst
> + ((head tail ...)
> + (match head
> + ((('type . x) other ...)
> + (cons head (flatten tail)))
> + (_
> + (append (flatten head) (flatten tail)))))))))
> +
> (make-page "sources.json"
> - `(("sources" . ,(list->vector (map package->json (all-packages))))
> + `(("sources" . ,(list->vector (flatten (map package->json (all-packages)))))
Maybe we should just change ‘package->json’ to always return a list of
JSON records (alists)? That way, we would write:
(append-map package->json (all-packages))
which I find slightly clearer.
WDYT?
Otherwise LGTM, thanks!
Ludo’.
This bug report was last modified 3 years and 209 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.