apteryx pushed a commit to branch master
in repository guix.

commit a0ce5501ca5cb5f8ac53d07797a2a992f00b3077
Author: Tomas Volf <[email protected]>
AuthorDate: Tue Apr 1 00:10:16 2025 +0200

    services: Add gitolite-git-configuration.
    
    In preparation for further customizability of the git configuration, extract
    the current setup into a separate record type.
    
    * gnu/services/version-control.scm (<gitolite-git-configuration>): New 
record
    type.
    (gitolite-git-configuration-compiler): And gexp compiler for it.
    (<gitolite-configuration>): Add git-config field.
    (gitolite-activation): Use it.
    * doc/guix.texi (Version Control Services): Document both.
    
    Change-Id: I7658698a93f938f62f41a4fa45b72de1eeb14414
    Signed-off-by: Maxim Cournoyer <[email protected]>
---
 doc/guix.texi                    | 17 +++++++++++++++++
 gnu/services/version-control.scm | 37 ++++++++++++++++++++++++++++++-------
 2 files changed, 47 insertions(+), 7 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index 0d1bbc6cd6..88eae4d782 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -41006,6 +41006,10 @@ Directory in which to store the Gitolite configuration 
and repositories.
 A ``file-like'' object (@pxref{G-Expressions, file-like objects}),
 representing the configuration for Gitolite.
 
+@item @code{git-config} (default: @code{(gitolite-git-configuration)})
+A ``file-like'' object (@pxref{G-Expressions, file-like objects}),
+representing the git configuration for Gitolite.
+
 @item @code{admin-pubkey} (default: @code{#f})
 A ``file-like'' object (@pxref{G-Expressions, file-like objects}) used to
 setup Gitolite.  This will be inserted in to the @file{keydir} directory
@@ -41081,6 +41085,19 @@ Extra content to add verbatim into the @code{%RC} hash.
 @end table
 @end deftp
 
+@deftp {Data Type} gitolite-git-configuration
+Data type representing the git configuration file for gitolite.
+
+@table @asis
+@item @code{name} (default: @code{"GNU GNU"})
+User name used for commits (e.g. during setting up the admin
+repository).
+
+@item @code{email} (default: @code{"guix@@localhost"})
+Email used for commits (e.g. during setting up the admin repository).
+
+@end table
+@end deftp
 
 @subsubheading Gitile Service
 
diff --git a/gnu/services/version-control.scm b/gnu/services/version-control.scm
index 268b0a47ee..dcdddf8078 100644
--- a/gnu/services/version-control.scm
+++ b/gnu/services/version-control.scm
@@ -67,6 +67,12 @@
             gitolite-rc-file-extra-content
             gitolite-rc-file-default-enable
 
+            <gitolite-git-configuration>
+            gitolite-git-configuration
+            gitolite-git-configuration?
+            gitolite-git-configuration-name
+            gitolite-git-configuration-email
+
             gitolite-service-type
 
             gitile-configuration
@@ -321,6 +327,23 @@ access to exported repositories under @file{/srv/git}."
              "# End:\n"
              "# vim: set syn=perl:\n"))))
 
+(define-record-type* <gitolite-git-configuration>
+  gitolite-git-configuration make-gitolite-git-configuration
+  gitolite-git-configuration?
+  (name gitolite-git-configuration-name
+        (default "GNU Guix"))
+  (email gitolite-git-configuration-email
+         (default "guix@localhost")))
+
+(define-gexp-compiler (gitolite-git-configuration-compiler
+                       (config <gitolite-git-configuration>) system target)
+  (match-record config <gitolite-git-configuration>
+                (name email)
+    (apply text-file* "gitconfig"
+           `("[user]\n"
+             "name  = " ,name  "\n"
+             "email = " ,email "\n"))))
+
 (define-record-type* <gitolite-configuration>
   gitolite-configuration make-gitolite-configuration
   gitolite-configuration?
@@ -334,6 +357,8 @@ access to exported repositories under @file{/srv/git}."
                   (default "/var/lib/gitolite"))
   (rc-file        gitolite-configuration-rc-file
                   (default (gitolite-rc-file)))
+  (git-config     gitolite-configuration-git-config
+                  (default (gitolite-git-configuration)))
   (admin-pubkey   gitolite-configuration-admin-pubkey))
 
 (define (gitolite-accounts config)
@@ -352,7 +377,8 @@ access to exported repositories under @file{/srv/git}."
 
 (define (gitolite-activation config)
   (match-record config <gitolite-configuration>
-                (package user group home-directory rc-file admin-pubkey)
+                ( package user group home-directory rc-file admin-pubkey
+                  git-config)
     #~(begin
         (use-modules (ice-9 match)
                      (guix build utils))
@@ -390,12 +416,9 @@ access to exported repositories under @file{/srv/git}."
 
           ;; Set the git configuration, to avoid gitolite trying to use
           ;; the hostname command, as the network might not be up yet
-          (with-output-to-file #$(string-append home-directory "/.gitconfig")
-            (lambda ()
-              (display "[user]
-        name = GNU Guix
-        email = guix@localhost
-")))
+          (copy-file #$git-config
+                     #$(string-append home-directory "/.gitconfig"))
+
           ;; Run Gitolite setup, as this updates the hooks and include the
           ;; admin pubkey if specified. The admin pubkey is required for
           ;; initial setup, and will replace the previous key if run after

Reply via email to