[PATCH] DRAFT: narinfo hooks for ‘guix publish’

  • Open
  • quality assurance status badge
Details
2 participants
  • Jonathan Brielmaier
  • Maxime Devos
Owner
unassigned
Submitted by
Maxime Devos
Severity
normal
M
M
Maxime Devos wrote on 31 Jan 2021 12:11
(address . guix-patches@gnu.org)
20432b68d12d95a23ae3713e8a904bf9dfc003e1.camel@telenet.be
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
Attachment: file
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-----


M
M
Maxime Devos wrote on 1 Feb 2021 21:17
(address . 46214@debbugs.gnu.org)
4371abecd37a0546ff29c04b98dad628a4db2801.camel@telenet.be
I've began writing tests, will post all patches here
(hook code, tests, service-extension code for
guix-publish-service-type and system tests) once
they are completed.
-----BEGIN PGP SIGNATURE-----

iI0EABYIADUWIQTB8z7iDFKP233XAR9J4+4iGRcl7gUCYBhhxhccbWF4aW1lZGV2
b3NAdGVsZW5ldC5iZQAKCRBJ4+4iGRcl7ou2AQDcQ6s5nnc0rskdAFMuhtPz1TbS
7XRHeNFGq/CmR9oVcgD9HKdCRHqocBS7HW2uUaowG7ddytPVnQHUMnnKnYYd+AM=
=GYC0
-----END PGP SIGNATURE-----


J
J
Jonathan Brielmaier wrote on 1 Feb 2021 23:22
Re: [bug#46214] [PATCH] DRAFT: narinfo hook s for ‘guix publish’
(address . guix-patches@gnu.org)
1c38257e-3fcd-8386-ba36-3206b83b3efa@web.de
On 31.01.21 12:11, Maxime Devos wrote:
Toggle quote (12 lines)
> 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.
I didn't looked really into the code, but would this also allow hooks
like baking the nar-file and write it into the cache? Or is it only for
the narinfos?
M
M
Maxime Devos wrote on 16 Feb 2021 20:26
Re: [bug#46214] [PATCH] DRAFT: narinfo hooks for ‘guix publish’
(name . Jonathan Brielmaier)(address . jonathan.brielmaier@web.de)(address . 46214@debbugs.gnu.org)
82868c60682e9134acbd98bfe450ea0e42804096.camel@telenet.be
Sorry for the late response, for some reason your mail didn't end
up in my inbox. A reminder for what my goal is: I am attempting
to serve substitutes via a P2P system. Ludovic has a patch
for substitutes over IPFS, myself I'm planning to write a patch
for substitutes over GNUnet. This patch aims to define a
simple ‘hook’ into ‘guix publish’ for adding the IPFS or GNUnet
URI.

On Mon, 2021-02-01 at 23:22 +0100, Jonathan Brielmaier wrote:
Toggle quote (9 lines)
>
> On 31.01.21 12:11, Maxime Devos wrote:
> > [...]
> > I've defined a ‘narinfo-hook’, which allows adding extra
> > key value pairs to the generated narinfos. [...]
> I didn't looked really into the code, but would this also allow hooks
> like baking the nar-file and write it into the cache? Or is it only for
> the narinfos?

This patch is only for the generation of the narinfos.

(I would like to eventually write a hook that publishes
the store item via GNUnet and embeds the URI in the narinfo,
but there isn't yet a corresponding hook mechanism on
the substituter side.)

That said, other hook types could be defined with additional
patches, though I don't know what use that would serve.

Greetings,
Maxime.
-----BEGIN PGP SIGNATURE-----

iI0EABYIADUWIQTB8z7iDFKP233XAR9J4+4iGRcl7gUCYCwcbxccbWF4aW1lZGV2
b3NAdGVsZW5ldC5iZQAKCRBJ4+4iGRcl7iAWAQC3m9thtJqYVq0KWVPfn8K9QM/B
IUIftGzTf33gAt7H4wD+I74YZNoky5A4Sm2PLu1XAUPNLKOjFVd743JGmadyWww=
=jrR8
-----END PGP SIGNATURE-----


?
Your comment

Commenting via the web interface is currently disabled.

To comment on this conversation send an email to 46214@debbugs.gnu.org

To respond to this issue using the mumi CLI, first switch to it
mumi current 46214
Then, you may apply the latest patchset in this issue (with sign off)
mumi am -- -s
Or, compose a reply to this issue
mumi compose
Or, send patches to this issue
mumi send-email *.patch