Subject: [bug#75981] [PATCH (WIP) v1 0/4] Add 'guix fork'.

From: 45mg <[email-masked]>
Date: Sat, 1 Feb 2025 02:40:08 +0530

Please ignore bugs #75973 and #75975. Those were both attempts to send this
patch series, but I sent the first one out before it was done and somehow
messed up the 'CC' and 'In-Reply-To' fields of the second. The best I can do
is close them and try again. Hopefully I'll get it right this time. (The 'v1'
in the subject line here is to differentiate this attempt from those ones.)

Hello Guix,

This patch series aims to enable and automate the creation and management of
authenticated local forks of Guix. The purpose of this work is to allow
contributors to use their own patches before they're applied to
upstream Guix, so that their own use of Guix is not hindered by the slow and
erratic pace of patch review.

This is a solution to bug #75552 [1], in whose discussion thread the design
was conceived and refined. Credit goes to Tomas for being the first person (to
my knowledge) to share their solution to this problem [2], which provided a
blueprint for 'guix fork create'; to Liliana for the idea behind the way 'guix
fork update' works [3]; and to Ricardo for the idea behind 'guix fork
identify' [4]. I've also CC'ed Attila and Nicolas since they replied in the
original thread (apologies in advance if I shouldn't have).

As I mentioned in the original thread [5], this solution aims to satisfy four
conditions which are not met by any existing method to my knowledge:

1. Allows authenticating both upstream and fork commits.
2. Does not require bumping the channel introduction (as distributing channel
introductions is sensitive)
3. Keeps fork history intact (to avoid force pulls).
4. Keeps upstream history intact (to avoid confusion).

Despite the '(WIP)' subject prefix, this patch series should be perfectly
usable in its current state. The easiest way to try it out would be as follows:

1. Apply it to your local clone of Guix (eg. in a branch) and build it.
2. 'cp -r' your local clone to another location.
3. Run the following command:
./pre-inst-env guix fork create <fingerprint-of-your-key> path/to/copy/of/local/clone --use-existing

Now you have the setup needed for an authenticated local fork. From here, you
can create and 'guix pull' (with authentication) from branches starting from
the initial fork commit. You can authenticate both fork and upstream using
'guix fork authenticate', even if the key used to create your fork is not
authorized upstream. You can update your fork with new commits from upstream
using 'guix fork update'.

The documentation (additions to doc/guix.texi and doc/contributing.texi)
should provide a proper overview of these commands and their usage. Easiest
way to view it could be to run 'make doc/guix.html' and then open it in a
browser.

The '(WIP)' subject prefix is there because the following things are yet to be
implemented:
1. The 'guix fork identify' command.
2. Tests, along the lines of tests/guix-git-authenticate.sh.

The code here adapts certain procedures from Tomas Volf's original 'fork-guix'
script [6]; namely: '-->', 'invoke/c', 'create-keyring-branch', 'git-C', and
'git-C/c'. That script is licensed under AGPL, so my understanding is that it,
or the procedures I used from it, would need to be relicensed under GPLv3 to
be included into Guix. Tomas - could you confirm here that you're willing to
do so, as we discussed earlier? (Note that I didn't ask you about the last two
of the five procedures above, since I hadn't used them yet at the time.)

Regards,
45mg

P.S It was helpfully explained to me [8] (in a reply to one of my previous
botched attempts to send this out) that since this patch series modifies (guix
build utils), it will result in almost every derivation changing and almost
everything needing to be rebuilt. I may send a v1.5 that moves those changes
elsewhere, so that it's feasible to 'guix pull' from a clone with this series
applied. Until then, you can test things via pre-inst-env.

[1] https://issues.guix.gnu.org/75552
[2] https://lists.gnu.org/archive/html/help-guix/2023-09/msg00078.html
[3] https://lists.nongnu.org/archive/html/bug-guix/2025-01/msg00139.html
[4] https://lists.nongnu.org/archive/html/bug-guix/2025-01/msg00130.html
[5] https://lists.nongnu.org/archive/html/bug-guix/2025-01/msg00135.html
[6] https://git.wolfsden.cz/guix/tree/etc/fork-guix
[7] https://ci.guix.gnu.org/eval/2036099
[8] https://lists.gnu.org/archive/html/guix-patches/2025-01/msg02844.html

45mg (4):
  Add 'guix fork create'.
  Add 'guix fork authenticate'.
  Add 'guix fork update'.
  Document 'guix fork'.

 Makefile.am                        |   4 +
 doc/contributing.texi              |  50 +++++
 doc/guix.texi                      | 150 +++++++++++++
 guix/build/utils.scm               |  20 ++
 guix/channels.scm                  |  13 ++
 guix/git-authenticate.scm          |  17 ++
 guix/git.scm                       |  10 +
 guix/scripts/fork.scm              |  71 +++++++
 guix/scripts/fork/authenticate.scm | 331 +++++++++++++++++++++++++++++
 guix/scripts/fork/create.scm       | 257 ++++++++++++++++++++++
 guix/scripts/fork/update.scm       | 181 ++++++++++++++++
 guix/scripts/git/authenticate.scm  |  45 +---
 guix/utils.scm                     |  33 +++
 13 files changed, 1141 insertions(+), 41 deletions(-)
 create mode 100644 guix/scripts/fork.scm
 create mode 100644 guix/scripts/fork/authenticate.scm
 create mode 100644 guix/scripts/fork/create.scm
 create mode 100644 guix/scripts/fork/update.scm

base-commit: b85d20e853192a92093cd8d6a5756ec80e94c658
-- 
2.48.1