Subject: bug#44104: [patch] guix/scripts/publish: share signing key

From: "Amar M. Singh" <[email-masked]>
Date: Wed, 21 Oct 2020 03:01:44 +0530

Add procedure (render-signing-key) and use it to serve the signing key.

Cheers

>From 554416649b7400d0bbe440016c6a6a7fed0d870a Mon Sep 17 00:00:00 2001
From: Amar Singh <[email-masked]>
Date: Wed, 21 Oct 2020 02:02:02 +0530
Subject: [PATCH] guix publish: We provide signing key. Knock yourselves out!

Best in industry.

Signed-off-by: Amar Singh <[email-masked]>
---
 guix/scripts/publish.scm | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/guix/scripts/publish.scm b/guix/scripts/publish.scm
index 4eaf961ab2..19df6d50ff 100644
--- a/guix/scripts/publish.scm
+++ b/guix/scripts/publish.scm
@@ -1,5 +1,6 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2015 David Thompson <[email-masked]>
+;;; Copyright (C) 2020 by Amar M. Singh <[email-masked]>
 ;;; Copyright © 2015, 2016, 2017, 2018, 2019, 2020 Ludovic Courtès <[email-masked]>
 ;;;
 ;;; This file is part of GNU Guix.
@@ -686,6 +687,13 @@ to compress or decompress the log file; just return it as-is."
         (values (response-headers log) log)
         (not-found request))))
 
+(define (render-signing-key)
+  "Render signing key."
+  (let ((file "/etc/guix/signing-key.pub"))
+    (values `((content-type . (text/plain (charset . "UTF-8")))
+              (x-raw-file . ,file))
+            file)))
+
 (define (render-home-page request)
   "Render the home page."
   (values `((content-type . (text/html (charset . "UTF-8"))))
@@ -699,7 +707,12 @@ to compress or decompress the log file; just return it as-is."
                                (a (@ (href
                                       "https://guix.gnu.org/manual/en/html_node/Invoking-guix-publish.html"))
                                   (tt "guix publish"))
-                               " speaking.  Welcome!")))
+                               " speaking.  Welcome!")
+                            (p "Here is the "
+                               (a (@ (href
+                                      "signing-key.pub"))
+                                  (tt "signing key"))
+                               " for this server. Knock yourselves out!")))
                          port)))))
 
 (define (extract-narinfo-hash str)
@@ -918,6 +931,9 @@ methods, return the applicable compression."
           ;; /
           ((or () ("index.html"))
            (render-home-page request))
+          ;; guix signing-key
+          (("signing-key.pub")
+           (render-signing-key))
           ;; /<hash>.narinfo
           (((= extract-narinfo-hash (? string? hash)))
            (if cache
-- 
2.28.0