[bug#77186,v2,14/14] services: gitolite-service-type: Allow setting the admin name.

Message ID 10ec1b1b255fb295438974862d806a2a19ed9754.1743459020.git.~@wolfsden.cz
State New
Headers
Series [bug#77186,v2,01/14] services: gitolite-rc-file-compiler: Switch to match-record. |

Commit Message

Tomas Volf March 31, 2025, 10:10 p.m. UTC
  * gnu/services/version-control.scm (<gitolite-configuration>): Add admin-name
field.
(gitolite-activation): Use it.
* doc/guix.texi (Version Control Services): Document it.  Remove the wrong
default value of admin-pubkey.  State the need for .pub extension.

Change-Id: Idadf4b2697cee6d1da10e6ba03bdc2e1d729c417
---
 doc/guix.texi                    |  9 ++++++++-
 gnu/services/version-control.scm | 17 +++++++++++------
 2 files changed, 19 insertions(+), 7 deletions(-)
  

Patch

diff --git a/doc/guix.texi b/doc/guix.texi
index ad4a623916..5db6f28f7d 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -41013,7 +41013,7 @@  Version Control Services
 A ``file-like'' object (@pxref{G-Expressions, file-like objects}),
 representing the git configuration for Gitolite.
 
-@item @code{admin-pubkey} (default: @code{#f})
+@item @code{admin-pubkey}
 A ``file-like'' object (@pxref{G-Expressions, file-like objects}) used to
 setup Gitolite.  This will be inserted in to the @file{keydir} directory
 within the gitolite-admin repository.
@@ -41024,6 +41024,13 @@  Version Control Services
 (plain-file "yourname.pub" "ssh-rsa AAAA... guix@@example.com")
 @end lisp
 
+The file has to have @file{.pub} extension.
+
+@item @code{admin-name} (default: @code{#f})
+Usually the key name is derived by taking a base name of the
+@code{admin-pubkey}.  The resulting file name is the name of the
+gitolite user.  You can use this field to override the automatic name.
+
 @end table
 @end deftp
 
diff --git a/gnu/services/version-control.scm b/gnu/services/version-control.scm
index e73e77e0b2..51da1c59cb 100644
--- a/gnu/services/version-control.scm
+++ b/gnu/services/version-control.scm
@@ -53,6 +53,7 @@  (define-module (gnu services version-control)
             gitolite-configuration-user
             gitolite-configuration-rc-file
             gitolite-configuration-admin-pubkey
+            gitolite-configuration-admin-name
 
             <gitolite-rc-file>
             gitolite-rc-file
@@ -377,7 +378,9 @@  (define-record-type* <gitolite-configuration>
                   (default (gitolite-rc-file)))
   (git-config     gitolite-configuration-git-config
                   (default (gitolite-git-configuration)))
-  (admin-pubkey   gitolite-configuration-admin-pubkey))
+  (admin-pubkey   gitolite-configuration-admin-pubkey)
+  (admin-name     gitolite-configuration-admin-name
+                  (default #f)))
 
 (define (gitolite-accounts config)
   (match-record config <gitolite-configuration>
@@ -396,17 +399,19 @@  (define (gitolite-accounts config)
 (define (gitolite-activation config)
   (match-record config <gitolite-configuration>
                 ( package user group home-directory rc-file admin-pubkey
-                  git-config)
+                  admin-name git-config)
     #~(begin
         (use-modules (ice-9 match)
                      (guix build utils))
 
         (let* ((user-info (getpwnam #$user))
                (admin-pubkey #$admin-pubkey)
-               (pubkey-file (string-append
-                             #$home-directory "/"
-                             (basename
-                              (strip-store-file-name admin-pubkey))))
+               (pubkey-file (if #$admin-name
+                                (string-append #$admin-name ".pub")
+                                (string-append
+                                 #$home-directory "/"
+                                 (basename
+                                  (strip-store-file-name admin-pubkey)))))
                (rc-file #$(string-append home-directory "/.gitolite.rc")))
 
           ;; activate-users+groups in (gnu build activation) sets the