diff options
author | EuAndreh <eu@euandre.org> | 2024-08-18 21:47:13 -0300 |
---|---|---|
committer | EuAndreh <eu@euandre.org> | 2024-08-18 21:49:16 -0300 |
commit | 957fc68374769e18e36c5924c3205019b6dc2451 (patch) | |
tree | 8f32f147ce080a0a63e9a3763fde678a188c5a55 /src | |
parent | packages.scm: Explicitly export functions that take rest parameters (diff) | |
download | packages-957fc68374769e18e36c5924c3205019b6dc2451.tar.gz packages-957fc68374769e18e36c5924c3205019b6dc2451.tar.xz |
packages.scm: Add git-service-type
Diffstat (limited to 'src')
-rw-r--r-- | src/org/euandre/packages.scm | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/src/org/euandre/packages.scm b/src/org/euandre/packages.scm index 6257992..a250780 100644 --- a/src/org/euandre/packages.scm +++ b/src/org/euandre/packages.scm @@ -513,6 +513,92 @@ +(define-record-type* <git-configuration> + git-configuration + make-git-configuration + git-configuration? + (package git-configuration-package (default git)) + (user git-configuration-user (default "git")) + (group git-configuration-group (default "git")) + (export-all? git-configuration-export-all? (default #f)) + (base-path git-configuration-base-path (default "/srv/git")) + (user-path git-configuration-user-path (default #f)) + (run-in-container? git-configuration-run-in-container? (default #f)) + (container-name git-configuration-container-name (default "git-container"))) + +(define-public (git-command config) + (match-record config <git-configuration> + (package user group base-path run-in-container? container-name) + (let ((bin (file-append package "/bin/git"))) + (if (not run-in-container?) + bin + (least-authority-wrapper + bin + #:user user + #:group group + #:name container-name + #:directory base-path + #:preserved-environment-variables + '() + #:mappings + (list + (file-system-mapping + (source base-path) + (target source) + (writable? #t)))))))) + +(define-public (git-shepherd-services config) + (match-record config <git-configuration> + (user group export-all? base-path user-path) + (list + (shepherd-service + (provision '(git)) + (requirement '(networking)) + (start + #~(make-forkexec-constructor + (list #$(git-command config) + "daemon" "--syslog" "--reuseaddr" + #$@(mklist (and export-all? "--export-all")) + #$@(mklist (and base-path (str "--base-path=" base-path))) + #$@(mklist (and user-path (str "--user-path=" user-path)))) + #:user #$user + #:group #$group)) + (stop #~(make-kill-destructor SIGKILL)) + (documentation "Daemon process of the git:// protocol."))))) + +(define-public (git-accounts config) + (match-record config <git-configuration> + (user group base-path) + (list + (user-account + (name user) + (group group) + (system? #t) + (comment "External SSH Git service user") + (home-directory base-path) + (create-home-directory? #f) + (shell + (file-append git "/bin/git-shell"))) + (user-group + (name group) + (system? #t))))) + +(define-public git-service-type + (service-type + (name 'git) + (extensions + (list + (service-extension shepherd-root-service-type + git-shepherd-services) + (service-extension account-service-type + git-accounts) + (service-extension profile-service-type + (compose list git-configuration-package)))) + (default-value (git-configuration)) + (description "Better git:// service."))) + + + (define-record-type* <binder-configuration> binder-configuration make-binder-configuration |