guix-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

not a patch.. yet. git-daemon-service


From: ng0
Subject: not a patch.. yet. git-daemon-service
Date: Fri, 17 Jun 2016 23:10:45 +0000

I've been working on understanding and applying to my first shepherd service.
There are maybe syntax errors, I did not look at it yet this way nor did
I run it.
I have some general questions which I will write into the code, not code
related questions. I will clean up, check up and fix and then ask about
the code.

Well coming back to it, I only have one question, but with this I can
give you a view on what I intend to do (and which I will fix).

> ;;; GNU Guix --- Functional package management for GNU
> ;;; Copyright © 2016 ng0 <address@hidden>
> ;;;
> ;;; This file is part of GNU Guix.
> ;;;
> ;;; GNU Guix is free software; you can redistribute it and/or modify it
> ;;; under the terms of the GNU General Public License as published by
> ;;; the Free Software Foundation; either version 3 of the License, or (at
> ;;; your option) any later version.
> ;;;
> ;;; GNU Guix is distributed in the hope that it will be useful, but
> ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
> ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> ;;; GNU General Public License for more details.
> ;;;
> ;;; You should have received a copy of the GNU General Public License
> ;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.

> (define-module (gnu services version-control)
>   #:use-module (gnu services)
>   #:use-module (gnu services base)
>   #:use-module (gnu services shepherd)
>   #:use-module (gnu system shadow)
>   #:use-module (gnu packages version-control)
>   #:use-module (gnu packages admin)
>   #:use-module (guix records)
>   #:use-module (guix gexp)
>   #:export (git-daemon-service
>             git-daemon-service-type))

> ;;; Commentary:
> ;;;
> ;;; Version Control related services.
> ;;;
> ;;; Code:

> 
> ;;;
> ;;; Git.
> ;;;

> (define-record-type* <git-daemon-configuration>
>   git-daemon-configuration make-git-daemon-configuration
>   git-daemon-configuration?
>   (git-daemon     git-daemon-configuration-git
>                   (default git))
>   (base-path      git-daemon-configuration-base-path) ; string
>   (port           git-daemon-configuration-port) ; string (default: 9418)
>   (extra-settings git-daemon-configuration-extra-settings))
>   ;;(export-all              git-daemon-configuration-export-all?) ;; those 
> are switches I need to add differently
>   ;;(informative-errors      git-daemon-configuration-informative-errors?) ;; 
> same.
>   ;;(verbose                 git-daemon-configuration-verbose?)) ;; same.

There are many settings. The ones I think are the very basic ones which can
be used for a start for this service are:
port, base-path, a forced --syslog --informative-errors and finally the option
to add whatever you want to add when you read the man page.
There are more we can add later, but those are the very basic in my opinion.
What's your opinion?

> ;; todo?: create repo folders and include them in the system generations?
> (define %git-daemon-activation
>   ;; Activation gexp.
>   #~(begin
>       (use-modules (guix build utils))
>       (mkdir-p "/var/run/git-daemon")))

> (define git-daemon-shepherd-service
>   (match-lambda
>    (($ <git-daemon-configuration> git-daemon base-path port extra-settings)
>     (let ((conf (string-append "
> --base-path="base-path"
> --port="(number->string port)"
> " extra-settings))))
>     (list (shepherd-service
>            (provision '(git-daemon))
>            (requirement '(networking loopback syslog)) ;; syslog?
>            (documentation "Run the git daemon server for git repositories.")
>            (start #~(make-forkexec-constructor
>                      (list (string-append #$git-daemon "/bin/git")
>                            "daemon" "--syslog" "--informative-errors"
>                            #$conf)))
>            (stop #~(make-kill-destructor)))))))

> (define %git-daemon-accounts
>   ;; User account and groups for git-daemon.
>   (list (user-group (name "git") (system? #t))
>         (user-account
>          (name "git")
>          (group "git")
>          (system? #t)
>          (comment "git daemon user")
>          (home-directory "/var/empty")
>          (shell #~(string-append #$shadow "/sbin/nologin")))))

> (define git-daemon-service-type
>   (service-type (name 'git-daemon)
>                 (extensions
>                  (list (service-extension shepherd-root-service-type
>                                           git-daemon-shepherd-service)
>                        (service-extension activation-service-type
>                                           (const %git-daemon-activation))
>                        ;; Add git-daemon to the global profile.
>                        (service-extension profile-service-type list)))))

> (define* (git-daemon-service #:key (git git)
>                              (extra-settings "")
>                              base-path
>                              (port 9418))
>   "Return a service that runs @url{https://git-scm.org,git} as a daemon,
> etc...

> The daemon will listen on the port specified in @var{port}.

> In addition, @var{extra-settings} specifies a string to append to the
> daemon parameters."
>   (service git-daemon-service-type
>            (git-daemon-configuration
>             (git git) (base-path base-path)
>             (port port) (extra-settings extra-settings))))

--
♥Ⓐ ng0
For non-prism friendly talk find me on
psyced.org / loupsycedyglgamf.onion

Attachment: signature.asc
Description: Digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]