Subject: Re: bug#61483: [PATCH 0/5] Some basic Home Shepherd Services

From: Ludovic Courtès <[email-masked]>
Date: Sat, 04 Mar 2023 18:05:02 +0100

"Jan (janneke) Nieuwenhuizen" <[email-masked]> skribis:

> * gnu/home/services/shepherd-xyz.scm: New file.
> * gnu/local.mk (GNU_SYSTEM_MODULES): Add it.

I’d make it version-control.scm instead.

> +(define-record-type* <home-git-daemon-configuration>
> +  home-git-daemon-configuration make-home-git-daemon-configuration
> +  home-git-daemon-configuration?
> +  (git           home-git-daemon-git                     ;file-like
> +                 (default git))
> +  (root          home-git-daemon-root                    ;string
> +                 (default (string-append %user-data-home
> +                                         "/git-daemon")))
> +  (export-all?   home-git-daemon-export-all?             ;boolean
> +                 (default #f))
> +  (listen        home-git-daemon-configuration-listen    ;list of string
> +                 (default '()))
> +  (port          home-git-daemon-configuration-port      ;number | #f
> +                 (default #f))
> +  (whitelist     home-git-daemon-configuration-whitelist ;list of string
> +                 (default '()))
> +  (extra-options home-git-daemon-extra-options           ;list of string
> +                 (default '())))
> +
> +(define (home-git-daemon-services config)
> +  "Return a <shepherd-service> for a git daemon with CONFIG."
> +  (match config
> +    (($ <home-git-daemon-configuration>
> +        git root export-all? listen port whitelist extra-options)
> +     (let* ((git (file-append git "/bin/git"))
> +            (command `(,git
> +                       "daemon"
> +                       ,(string-append "--base-path=" root)
> +                       ,@(if export-all?
> +                             '("--export-all")
> +                             '())
> +                       ,@(map (cute string-append "--listen=" <>) listen)
> +                       ,@(if port
> +                             `(,(string-append
> +                                 "--port=" (number->string port)))
> +                             '())
> +                       ,@extra-options
> +                       ,@whitelist))
> +            (log-file (string-append %user-log-dir "/git-daemon.log")))
> +       (list (shepherd-service
> +              (documentation "Run the git daemon.")
> +              (provision '(git-daemon))
> +              (start #~(make-forkexec-constructor '#$command
> +                                                  #:log-file #$log-file))
> +              (stop #~(make-kill-destructor))))))))

I have a prototype here to “transform” a System service into a Home
service.  Would it be of any use here, to share code with
‘git-daemon-service-type’?

Looks like the only issue would be #:user "git-daemon", which is not
going to work, and I don’t have a good solution to that.  :-/

Ludo’.