summaryrefslogtreecommitdiff
path: root/gnu/services
diff options
context:
space:
mode:
authorAndy Wingo <wingo@igalia.com>2017-04-27 15:02:19 +0200
committerAndy Wingo <wingo@igalia.com>2017-04-27 20:24:43 +0200
commitcb9f33e2a70b304cc5712d8a369dc8db7a8ae95b (patch)
tree47b2dca6fc2132066c38549dd7e128f2215738ae /gnu/services
parent80d872ae8362b5e769c463599b03ddb0fb7482d2 (diff)
gnu: Add Git HTTP(S) service support.wip-git-https
* doc/guix.texi (Version Control Services): Add documentation on the HTTP backend for git. * gnu/services/version-control.scm (<git-http-configuration>): New data type. (git-http-nginx-location-configuration): New helper function.
Diffstat (limited to 'gnu/services')
-rw-r--r--gnu/services/version-control.scm54
1 files changed, 53 insertions, 1 deletions
diff --git a/gnu/services/version-control.scm b/gnu/services/version-control.scm
index 107bc8e77a..125d63653f 100644
--- a/gnu/services/version-control.scm
+++ b/gnu/services/version-control.scm
@@ -21,6 +21,7 @@
#:use-module (gnu services)
#:use-module (gnu services base)
#:use-module (gnu services shepherd)
+ #:use-module (gnu services web)
#:use-module (gnu system shadow)
#:use-module (gnu packages version-control)
#:use-module (gnu packages admin)
@@ -32,7 +33,11 @@
#:export (git-daemon-service
git-daemon-service-type
git-daemon-configuration
- git-daemon-configuration?))
+ git-daemon-configuration?
+
+ git-http-configuration
+ git-http-configuration?
+ git-http-nginx-location-configuration))
;;; Commentary:
;;;
@@ -139,3 +144,50 @@ The optional @var{config} argument should be a
@code{<git-daemon-configuration>} object, by default it allows read-only
access to exported repositories under @file{/srv/git}."
(service git-daemon-service-type config))
+
+
+
+;;;
+;;; HTTP access. Add the result of calling
+;;; git-http-nginx-location-configuration to an nginx-server-configuration's
+;;; "locations" field.
+;;;
+
+(define-record-type* <git-http-configuration>
+ git-http-configuration
+ make-git-http-configuration
+ git-http-configuration?
+ (package git-http-configuration-package ;package
+ (default git))
+ (git-root git-http-configuration-git-root ;string
+ (default "/srv/git"))
+ (export-all? git-http-configuration-export-all? ;boolean
+ (default #f))
+ (uri-path git-http-configuration-uri-path ;string
+ (default "/git/"))
+ (fcgiwrap-socket git-http-configuration-fcgiwrap-socket ;string
+ (default "127.0.0.1:9000")))
+
+(define* (git-http-nginx-location-configuration #:optional
+ (config
+ (git-http-configuration)))
+ (match config
+ (($ <git-http-configuration> package git-root export-all?
+ uri-path fcgiwrap-socket)
+ (nginx-location-configuration
+ (uri (string-append "~ /" (string-trim-both uri-path #\/) "(/.*)"))
+ (body
+ (list
+ (list "fastcgi_pass " fcgiwrap-socket ";")
+ (list "fastcgi_param SCRIPT_FILENAME "
+ package "/libexec/git-core/git-http-backend"
+ ";")
+ "fastcgi_param QUERY_STRING $query_string;"
+ "fastcgi_param REQUEST_METHOD $request_method;"
+ "fastcgi_param CONTENT_TYPE $content_type;"
+ "fastcgi_param CONTENT_LENGTH $content_length;"
+ (if export-all?
+ "fastcgi_param GIT_HTTP_EXPORT_ALL \"\";"
+ "")
+ (list "fastcgi_param GIT_PROJECT_ROOT " git-root ";")
+ "fastcgi_param PATH_INFO $1;"))))))