guix-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug#50515] (guix-artwork)[PATCH 0/2] List linux origins in 'sources.jso


From: Ludovic Courtès
Subject: [bug#50515] (guix-artwork)[PATCH 0/2] List linux origins in 'sources.json'.
Date: Mon, 18 Oct 2021 14:23:49 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)

Hi!

zimoun <zimon.toutoune@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’.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]