[bug#77186,v2,04/13] services: gitolite-rc-file: Add extra-content field.

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

Commit Message

Tomas Volf March 22, 2025, 5:09 p.m. UTC
  * gnu/services/version-control.scm (<gitolite-rc-file>): Add extra-content
field.
(gitolite-rc-file-compiler): Handle it during configuration file generation.
* doc/guix.texi (Version Control Services): Document it.

Change-Id: I5082e1d7a27cc746641ba9ec8ae07c703da5f279
---
 doc/guix.texi                    | 3 +++
 gnu/services/version-control.scm | 8 ++++++--
 2 files changed, 9 insertions(+), 2 deletions(-)
  

Comments

Maxim Cournoyer March 27, 2025, 5:42 a.m. UTC | #1
Hi,

Tomas Volf <~@wolfsden.cz> writes:

> * gnu/services/version-control.scm (<gitolite-rc-file>): Add extra-content
> field.
> (gitolite-rc-file-compiler): Handle it during configuration file generation.
> * doc/guix.texi (Version Control Services): Document it.
>
> Change-Id: I5082e1d7a27cc746641ba9ec8ae07c703da5f279
> ---
>  doc/guix.texi                    | 3 +++
>  gnu/services/version-control.scm | 8 ++++++--
>  2 files changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/doc/guix.texi b/doc/guix.texi
> index 2c7ddb2f55..e60fef9673 100644
> --- a/doc/guix.texi
> +++ b/doc/guix.texi
> @@ -41164,6 +41164,9 @@ Version Control Services
>  @item @code{enable} (default: @code{'("help" "desc" "info" "perms" "writable" "ssh-authkeys" "git-config" "daemon" "gitweb")})
>  This setting controls the commands and features to enable within Gitolite.
>  
> +@item @code{extra-content} (default: @code{""})
> +Extra content to add verbatim into the @code{%RC} hash.

What is the %RC hash?

Otherwise, LGTM.
  
Tomas Volf March 27, 2025, 5:43 p.m. UTC | #2
Maxim Cournoyer <maxim.cournoyer@gmail.com> writes:

> Hi,
>
> Tomas Volf <~@wolfsden.cz> writes:
>
>> * gnu/services/version-control.scm (<gitolite-rc-file>): Add extra-content
>> field.
>> (gitolite-rc-file-compiler): Handle it during configuration file generation.
>> * doc/guix.texi (Version Control Services): Document it.
>>
>> Change-Id: I5082e1d7a27cc746641ba9ec8ae07c703da5f279
>> ---
>>  doc/guix.texi                    | 3 +++
>>  gnu/services/version-control.scm | 8 ++++++--
>>  2 files changed, 9 insertions(+), 2 deletions(-)
>>
>> diff --git a/doc/guix.texi b/doc/guix.texi
>> index 2c7ddb2f55..e60fef9673 100644
>> --- a/doc/guix.texi
>> +++ b/doc/guix.texi
>> @@ -41164,6 +41164,9 @@ Version Control Services
>>  @item @code{enable} (default: @code{'("help" "desc" "info" "perms" "writable" "ssh-authkeys" "git-config" "daemon" "gitweb")})
>>  This setting controls the commands and features to enable within Gitolite.
>>  
>> +@item @code{extra-content} (default: @code{""})
>> +Extra content to add verbatim into the @code{%RC} hash.
>
> What is the %RC hash?

It is the hash containing the configuration.  Gitolite's configuration
file is just a piece of perl source code, in the form of:

--8<---------------cut here---------------start------------->8---
%RC = (

    # ------------------------------------------------------------------

    # default umask gives you perms of '0700'; see the rc file docs for
    # how/why you might change this
    UMASK                           =>  0077,

    # look for "git-config" in the documentation
    GIT_CONFIG_KEYS                 =>  '',

    [...]
);

# ------------------------------------------------------------------------------
# per perl rules, this should be the last line in such a file:
1;
--8<---------------cut here---------------end--------------->8---

So this field is verbatim added at the end of the hash, serving as an
escape hatch to configure properties not yet supported by the
gitolite-rc-file.

I realize the description of the field requires some knowledge of how
gitolite is configured, and I am open to suggestions on how to improve
it, if you have any. :)

Tomas
  

Patch

diff --git a/doc/guix.texi b/doc/guix.texi
index 2c7ddb2f55..e60fef9673 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -41164,6 +41164,9 @@  Version Control Services
 @item @code{enable} (default: @code{'("help" "desc" "info" "perms" "writable" "ssh-authkeys" "git-config" "daemon" "gitweb")})
 This setting controls the commands and features to enable within Gitolite.
 
+@item @code{extra-content} (default: @code{""})
+Extra content to add verbatim into the @code{%RC} hash.
+
 @end table
 @end deftp
 
diff --git a/gnu/services/version-control.scm b/gnu/services/version-control.scm
index 2b99e8db86..9bd17334fe 100644
--- a/gnu/services/version-control.scm
+++ b/gnu/services/version-control.scm
@@ -64,6 +64,7 @@  (define-module (gnu services version-control)
             gitolite-rc-file-host-name
             gitolite-rc-file-roles
             gitolite-rc-file-enable
+            gitolite-rc-file-extra-content
 
             gitolite-service-type
 
@@ -270,13 +271,15 @@  (define-record-type* <gitolite-rc-file>
                               "ssh-authkeys"
                               "git-config"
                               "daemon"
-                              "gitweb"))))
+                              "gitweb")))
+  (extra-content   gitolite-rc-extra-content
+                   (default "")))
 
 (define-gexp-compiler (gitolite-rc-file-compiler
                        (file <gitolite-rc-file>) system target)
   (match-record file <gitolite-rc-file>
                 ( umask local-code unsafe-pattern git-config-keys log-extra
-                  host-name roles enable)
+                  host-name roles enable extra-content)
     (apply text-file* "gitolite.rc"
            `("%RC = (\n"
              "    UMASK => " ,(format #f "~4,'0o" umask) ",\n"
@@ -302,6 +305,7 @@  (define-gexp-compiler (gitolite-rc-file-compiler
                       (simple-format #f "        '~A',\n" value))
                     enable)
              "    ],\n"
+             ,extra-content "\n"
              ");\n"
              "\n"
              ,(if unsafe-pattern