;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2020 Julien Lepiller ;;; ;;; 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 . ;;; ;;; Some of the help text was taken from the default dovecot.conf files. (define-module (services gitile) #:use-module (gnu services) #:use-module (gnu services base) #:use-module (gnu services configuration) #:use-module (gnu services shepherd) #:use-module (gnu system pam) #:use-module (gnu system shadow) #:use-module (gnu packages admin) #:use-module (packages gitile) #:use-module (guix gexp) #:use-module (guix records) #:use-module (ice-9 match) #:export (gitile-service-type gitile-configuration)) (define-record-type* gitile-configuration make-gitile-configuration gitile-configuration? (package gitile-configuration-package (default gitile)) (host gitile-configuration-host (default "localhost")) (port gitile-configuration-port (default 8080)) (database gitile-configuration-database (default "/var/lib/gitile/gitile-db.sql")) (repositories gitile-configuration-repositories (default "/var/lib/gitolite/repositories"))) (define (gitile-config-file host port database repositories) (define build #~(write `(config (port #$port) (host #$host) (database #$database) (repositories #$repositories)) (open-output-file #$output))) (computed-file "gitile.conf" build)) (define gitile-shepherd-service (match-lambda (($ package host port database repositories) (list (shepherd-service (provision '(gitile)) (requirement '(loopback)) (documentation "gitile") (start (let ((gitile (file-append package "/bin/gitile"))) #~(make-forkexec-constructor `(,#$gitile "-c" #$(gitile-config-file host port database repositories)) #:user "gitile" #:group "git"))) (stop #~(make-kill-destructor))))))) (define %gitile-accounts (list (user-account (name "gitile") (group "git") (system? #t) (comment "Gitile user") (home-directory "/var/empty") (shell (file-append shadow "/sbin/nologin"))))) (define gitile-service-type (service-type (name 'gitile) (extensions (list (service-extension account-service-type (const %gitile-accounts)) (service-extension shepherd-root-service-type gitile-shepherd-service))) (default-value (gitile-configuration))))