(address . guix-patches@gnu.org)
Hello Guix!
I've a proposal to make ‘guix publish’ somewhat extensible.
The draft patch allows for passing a list of ‘hooks’ to guix
publish, with "guix publish --hooks=FILE-WITH-HOOKS.scm
--hooks=MORE-HOOKS.go". "guix publish" then will consult
this list of hooks at some points.
I've defined a ‘narinfo-hook’, which allows adding extra
key value pairs to the generated narinfos. See the last
patch that adds a ‘hook.scm’ file for a silly example
that includes a random number and some arbitrary strings.
A TODO for a future revision of the patch, is modifying
‘guix-publish-service-type’ to allow passing a list of
hooks (as gexps).
The use case I had in mind: this could be used for Guix+IPFS
and Guix+GNUnet integration (at least on the "guix publish"
side), by implementing a hook that inserts the store item
into IPFS and GNUnet respectively, and add an appropriate
IPFS and GNUnet URI.
(I'll look into appropriate "guix substitute" hooks
later.)
Guix+IPFS and Guix+GNUnet integrations could of course
use a forked guix (until the integration is merged
upstream when it is in a good state), but a hook system
seems more practical for experimentation to me.
(Also, if hypothetically, in the future "guix publish" supports,
say, IPFS, GNUnet, BitTorrent and Dat, then using the approach
of wip-ipfs-substitutes, there would be four keyword
arguments that need to be passed everywhere. This patch
only passes a single #:hooks argument.)
Also a question for guix-devel: the wip-ipfs-substitutes
patch adds the "IPFS: etcetera" line *after* the signed
part, while this patch only allows for addings key-value
pairs that will be signed. Would it be problematic for
the "IPFS: etcetera" or "GNUnet: etcetera" line to be
signed?
If this proposal seems OK to guix-devel, I'll write up
some documentation, tests and changes to
guix-publish-service-type.
(Patch can also be found as signed tag wip-publish-narinfo-hook0
Greetings,
Maxime
--
Maxime Devos <maximedevos@telenet.be>
PGP Key: C1F3 3EE2 0C52 8FDB 7DD7 011F 49E3 EE22 1917 25EE
Freenode handle: mdevos
From 61c681cbe0b29b31587e71a905f34f0f12757a13 Mon Sep 17 00:00:00 2001
From: Maxime Devos <maximedevos@telenet.be>
Date: Sun, 31 Jan 2021 11:06:46 +0100
Subject: [PATCH 2/2] DRAFT: add hook example
TODO: should be located elsewere.
---
hook.scm | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)
create mode 100644 hook.scm
Toggle diff (35 lines)
diff --git a/hook.scm b/hook.scm
new file mode 100644
index 0000000000..7b81c8d761
--- /dev/null
+++ b/hook.scm
@@ -0,0 +1,27 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2021 Maxime Devos <maximedevos@telenet.be>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
+(use-modules (guix scripts publish))
+
+(list
+ (narinfo-hook
+ (lambda (pathinfo . rest)
+ `(("LuckyNumber" . ,(random 1000))
+ ("Stuff" . ,(object->string pathinfo)))))
+ (narinfo-hook
+ (lambda (pathinfo . rest)
+ `(("Cool" . "Beans")))))
--
2.30.0
-----BEGIN PGP SIGNATURE-----
iI0EABYIADUWIQTB8z7iDFKP233XAR9J4+4iGRcl7gUCYBaQNhccbWF4aW1lZGV2
b3NAdGVsZW5ldC5iZQAKCRBJ4+4iGRcl7o2nAP9/vG9swo5z3kE4uetw5arQ3yZO
Y/fx01hvWYsWulySIQD/e5Ax3nRWa1YOJcIKc7J1Q/C6bVCABxev0US/NutNhAA=
=zpgF
-----END PGP SIGNATURE-----