summaryrefslogtreecommitdiff
path: root/website/apps/packages/builder.scm
diff options
context:
space:
mode:
Diffstat (limited to 'website/apps/packages/builder.scm')
-rw-r--r--website/apps/packages/builder.scm16
1 files changed, 16 insertions, 0 deletions
diff --git a/website/apps/packages/builder.scm b/website/apps/packages/builder.scm
index 40a54f9..00e177c 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 packages)
+ #:use-module (json)
#:export (builder))
@@ -62,6 +65,7 @@
(flatten
(list
(index-builder)
+ (packages-json-builder)
(packages-builder)
(package-list-builder))))
@@ -75,6 +79,18 @@
;; Maximum number of packages shown on /packages.
30)
+(define (packages-json-builder)
+ "Return a JSON page listing all packages."
+ (define (package->json package)
+ `(("name" . ,(package-name package))
+ ("version" . ,(package-version package))
+ ("synopsis" . ,(package-synopsis package))
+ ("homepage" . ,(package-home-page package))))
+ (make-page "packages.json"
+ (list->vector (map package->json (all-packages)))
+ (lambda args
+ (apply scm->json (append args '(#:pretty #t))))))
+
(define (index-builder)
"Return a Haunt page listing some random packages."
(define (sample n from)