(address . guix-patches@gnu.org)
Hi,
I'm sending a patch to guix-artwork. My aim was to help in getting this
issue (https://github.com/repology/repology/issues/218)fixed (and have
guix packages back on repology).
Probably is possible to add more fields, but they are not strictly required
(as per https://repology.org/addrepo)
Also, I don't know if (ab)using make-page that way is right. Any suggestion
is welcome.
Thanks, Nicolò
From 3949a27b653f25704ad57e95133ec9487bcd3ccb Mon Sep 17 00:00:00 2001
From: nixo <nicolo@nixo.xyz>
Date: Mon, 12 Aug 2019 16:42:08 +0200
Subject: [PATCH] website: export JSON package list to packages.json
---
website/apps/packages/builder.scm | 15 +++++++++++++++
1 file changed, 15 insertions(+)
Toggle diff (49 lines)
diff --git a/website/apps/packages/builder.scm b/website/apps/packages/builder.scm
index 59f86c1..fc08d6a 100644
--- a/website/apps/packages/builder.scm
+++ b/website/apps/packages/builder.scm
@@ -1,6 +1,7 @@
;;; GNU Guix web site
;;; Copyright © 2017 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2019 Ricardo Wurmus <rekado@elephly.net>
+;;; Copyright © 2019 Nicolò Balzarotti <nicolo@nixo.xyz>
;;;
;;; Initially written by sirgazil
;;; who waives all copyright interest on this file.
@@ -36,6 +37,8 @@
#:use-module (haunt page)
#:use-module (haunt utils)
#:use-module (srfi srfi-1)
+ #:use-module (guix)
+ #:use-module (json)
#:export (builder))
@@ -76,6 +79,7 @@
;; used instead. They should generate pages as those described
;; in the proposal.
(list
+ (package-json-builder)
(detailed-index-builder)
(detailed-package-list-builder)))))
@@ -101,6 +105,17 @@
(length (all-packages))))))
(make-page "packages/index.html" (index-t context) sxml->html)))
+(define (package-json-builder)
+ "Return a JSON listing all packages."
+ (define (package-fields package)
+ `(("name" ,(package-name package))
+ ("version" ,(package-version package))
+ ("synopsis" ,(package-synopsis package))
+ ("homepage" ,(package-home-page package))))
+ (define (packages->json packages)
+ (map package-fields packages))
+ (make-page "packages.json"
+ (packages->json (all-packages)) scm->json))
(define (detailed-index-builder)
"Return a Haunt page listing some random packages."
--
2.22.0