diff mbox series

[bug#46214] DRAFT: narinfo hooks for ‘guix publish’

Message ID 20432b68d12d95a23ae3713e8a904bf9dfc003e1.camel@telenet.be
State New
Headers show
Series [bug#46214] DRAFT: narinfo hooks for ‘guix publish’ | expand

Checks

Context Check Description
cbaines/submitting builds success
cbaines/comparison success View comparision
cbaines/git branch success View Git branch
cbaines/applying patch fail View Laminar job
cbaines/issue success View issue

Commit Message

M Jan. 31, 2021, 11:11 a.m. UTC
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
at https://notabug.org/mdevos/guix-gnunet.)

Greetings,
Maxime

Comments

M Feb. 1, 2021, 8:17 p.m. UTC | #1
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.
Jonathan Brielmaier Feb. 1, 2021, 10:22 p.m. UTC | #2
On 31.01.21 12:11, Maxime Devos wrote:
> 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 Feb. 16, 2021, 7:26 p.m. UTC | #3
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:
> 
> 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.
diff mbox series

Patch

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

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