gnu: r-purrr: Update to 0.3.0.
[jackhill/guix/guix.git] / gnu / services / cgit.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2018 Oleg Pykhalov <go.wigust@gmail.com>
3 ;;; Copyright © 2018 Clément Lassieur <clement@lassieur.org>
4 ;;; Copyright © 2018 Christopher Baines <mail@cbaines.net>
5 ;;;
6 ;;; This file is part of GNU Guix.
7 ;;;
8 ;;; GNU Guix is free software; you can redistribute it and/or modify it
9 ;;; under the terms of the GNU General Public License as published by
10 ;;; the Free Software Foundation; either version 3 of the License, or (at
11 ;;; your option) any later version.
12 ;;;
13 ;;; GNU Guix is distributed in the hope that it will be useful, but
14 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
15 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 ;;; GNU General Public License for more details.
17 ;;;
18 ;;; You should have received a copy of the GNU General Public License
19 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
20
21 (define-module (gnu services cgit)
22 #:use-module (gnu packages admin)
23 #:use-module (gnu packages version-control)
24 #:use-module (gnu services base)
25 #:use-module (gnu services configuration)
26 #:use-module (gnu services shepherd)
27 #:use-module (gnu services web)
28 #:use-module (gnu services)
29 #:use-module (gnu system shadow)
30 #:use-module (guix gexp)
31 #:use-module (guix packages)
32 #:use-module (guix records)
33 #:use-module (guix store)
34 #:use-module (ice-9 match)
35 #:use-module (srfi srfi-1)
36 #:use-module (srfi srfi-26)
37 #:export (repository-cgit-configuration
38 cgit-configuration
39 %cgit-configuration-nginx
40 cgit-configuration-nginx-config
41 opaque-cgit-configuration
42 cgit-service-type))
43
44 ;;; Commentary:
45 ;;;
46 ;;; This module provides a service definition for the Cgit a web frontend for
47 ;;; Git repositories written in C.
48 ;;;
49 ;;; Note: fields of <cgit-configuration> and <repository-cgit-configuration>
50 ;;; should be specified in the specific order.
51 ;;;
52 ;;; Code:
53
54 (define %cgit-configuration-nginx
55 (nginx-server-configuration
56 (root cgit)
57 (locations
58 (list
59 (nginx-location-configuration
60 (uri "@cgit")
61 (body '("fastcgi_param SCRIPT_FILENAME $document_root/lib/cgit/cgit.cgi;"
62 "fastcgi_param PATH_INFO $uri;"
63 "fastcgi_param QUERY_STRING $args;"
64 "fastcgi_param HTTP_HOST $server_name;"
65 "fastcgi_pass 127.0.0.1:9000;")))))
66 (try-files (list "$uri" "@cgit"))
67 (listen '("80"))
68 (ssl-certificate #f)
69 (ssl-certificate-key #f)))
70
71 \f
72 ;;;
73 ;;; Serialize <cgit-configuration>
74 ;;;
75
76 (define (uglify-field-name field-name)
77 (string-delete #\? (symbol->string field-name)))
78
79 (define (serialize-field field-name val)
80 #~(format #f "~a=~a\n" #$(uglify-field-name field-name) #$val))
81
82 (define (serialize-string field-name val)
83 (if (and (string? val) (string=? val ""))
84 ""
85 (serialize-field field-name val)))
86
87 (define (serialize-list field-name val)
88 (if (null? val) "" (serialize-field field-name (string-join val))))
89
90 (define robots-list? list?)
91
92 (define (serialize-robots-list field-name val)
93 (if (null? val) "" (serialize-field field-name (string-join val ", "))))
94
95 (define (integer? val)
96 (exact-integer? val))
97
98 (define (serialize-integer field-name val)
99 (serialize-field field-name (number->string val)))
100
101 (define (serialize-boolean field-name val)
102 (serialize-integer field-name (if val 1 0)))
103
104 (define (serialize-repository-cgit-configuration x)
105 (serialize-configuration x repository-cgit-configuration-fields))
106
107 (define (repository-cgit-configuration-list? val)
108 (list? val))
109
110 (define (serialize-repository-cgit-configuration-list field-name val)
111 #~(string-append
112 #$@(map serialize-repository-cgit-configuration val)))
113
114 (define (file-object? val)
115 (or (file-like? val) (string? val)))
116 (define (serialize-file-object field-name val)
117 (serialize-string field-name val))
118
119 (define (project-list? val)
120 (or (list? val)
121 (file-object? val)))
122
123 \f
124 ;;;
125 ;;; Serialize <nginx-server-configuration>
126 ;;;
127
128 (define (nginx-server-configuration-list? val)
129 (and (list? val) (and-map nginx-server-configuration? val)))
130
131 (define (serialize-nginx-server-configuration-list field-name val)
132 "")
133
134 \f
135 ;;;
136 ;;; Serialize <repository-cgit-configuration>
137 ;;;
138
139 (define (serialize-repo-field field-name val)
140 #~(format #f "repo.~a=~a\n" #$(uglify-field-name field-name) #$val))
141
142 (define (serialize-repo-list field-name val)
143 (if (null? val) "" (serialize-repo-field field-name (string-join val))))
144
145 (define repo-boolean? boolean?)
146
147 (define (serialize-repo-integer field-name val)
148 (serialize-repo-field field-name (number->string val)))
149
150 (define (serialize-repo-boolean field-name val)
151 (serialize-repo-integer field-name (if val 1 0)))
152 (define-maybe repo-boolean)
153
154 (define repo-list? list?)
155
156 (define repo-string? string?)
157
158 (define (serialize-repo-string field-name val)
159 (if (string=? val "") "" (serialize-repo-field field-name val)))
160
161 (define repo-file-object? file-object?)
162 (define serialize-repo-file-object serialize-repo-string)
163
164 (define module-link-path? list?)
165
166 (define (serialize-module-link-path field-name val)
167 (if (null? val) ""
168 (match val
169 ((path text)
170 (format #f "repo.module-link.~a=~a\n" path text)))))
171
172 (define (serialize-project-list _ val)
173 (if (null? val) ""
174 (serialize-field
175 'project-list
176 (if (file-object? val)
177 val
178 (plain-file "project-list" (string-join val "\n"))))))
179
180 (define (serialize-extra-options extra-options)
181 (string-join extra-options "\n" 'suffix))
182
183 (define repository-directory? string?)
184
185 (define (serialize-repository-directory _ val)
186 (if (string=? val "") "" (format #f "scan-path=~a\n" val)))
187
188 (define mimetype-alist? list?)
189
190 (define (serialize-mimetype-alist field-name val)
191 (format #f "# Mimetypes\n~a"
192 (string-join
193 (map (match-lambda
194 ((extension mimetype)
195 (format #f "mimetype.~a=~a"
196 (symbol->string extension) mimetype)))
197 val) "\n")))
198
199 (define-configuration repository-cgit-configuration
200 (snapshots
201 (repo-list '())
202 "A mask of snapshot formats for this repo that cgit generates links for,
203 restricted by the global @code{snapshots} setting.")
204 (source-filter
205 (repo-file-object "")
206 "Override the default @code{source-filter}.")
207 (url
208 (repo-string "")
209 "The relative URL used to access the repository.")
210 (about-filter
211 (repo-file-object "")
212 "Override the default @code{about-filter}.")
213 (branch-sort
214 (repo-string "")
215 "Flag which, when set to @samp{age}, enables date ordering in the branch
216 ref list, and when set to @samp{name} enables ordering by branch name.")
217 (clone-url
218 (repo-list '())
219 "A list of URLs which can be used to clone repo.")
220 (commit-filter
221 (repo-file-object "")
222 "Override the default @code{commit-filter}.")
223 (commit-sort
224 (repo-string "")
225 "Flag which, when set to @samp{date}, enables strict date ordering in the
226 commit log, and when set to @samp{topo} enables strict topological ordering.")
227 (defbranch
228 (repo-string "")
229 "The name of the default branch for this repository. If no such branch
230 exists in the repository, the first branch name (when sorted) is used as
231 default instead. By default branch pointed to by HEAD, or \"master\" if there
232 is no suitable HEAD.")
233 (desc
234 (repo-string "")
235 "The value to show as repository description.")
236 (homepage
237 (repo-string "")
238 "The value to show as repository homepage.")
239 (email-filter
240 (repo-file-object "")
241 "Override the default @code{email-filter}.")
242 (enable-commit-graph?
243 (maybe-repo-boolean 'disabled)
244 "A flag which can be used to disable the global setting
245 @code{enable-commit-graph?}.")
246 (enable-log-filecount?
247 (maybe-repo-boolean 'disabled)
248 "A flag which can be used to disable the global setting
249 @code{enable-log-filecount?}.")
250 (enable-log-linecount?
251 (maybe-repo-boolean 'disabled)
252 "A flag which can be used to disable the global setting
253 @code{enable-log-linecount?}.")
254 (enable-remote-branches?
255 (maybe-repo-boolean 'disabled)
256 "Flag which, when set to @code{#t}, will make cgit display remote
257 branches in the summary and refs views.")
258 (enable-subject-links?
259 (maybe-repo-boolean 'disabled)
260 "A flag which can be used to override the global setting
261 @code{enable-subject-links?}.")
262 (enable-html-serving?
263 (maybe-repo-boolean 'disabled)
264 "A flag which can be used to override the global setting
265 @code{enable-html-serving?}.")
266 (hide?
267 (repo-boolean #f)
268 "Flag which, when set to @code{#t}, hides the repository from the
269 repository index.")
270 (ignore?
271 (repo-boolean #f)
272 "Flag which, when set to @samp{#t}, ignores the repository.")
273 (logo
274 (repo-file-object "")
275 "URL which specifies the source of an image which will be used as a
276 logo on this repo’s pages.")
277 (logo-link
278 (repo-string "")
279 "URL loaded when clicking on the cgit logo image.")
280 (owner-filter
281 (repo-file-object "")
282 "Override the default @code{owner-filter}.")
283 (module-link
284 (repo-string "")
285 "Text which will be used as the formatstring for a hyperlink when a
286 submodule is printed in a directory listing. The arguments for the
287 formatstring are the path and SHA1 of the submodule commit.")
288 (module-link-path
289 (module-link-path '())
290 "Text which will be used as the formatstring for a hyperlink when a
291 submodule with the specified subdirectory path is printed in a directory
292 listing.")
293 (max-stats
294 (repo-string "")
295 "Override the default maximum statistics period.")
296 (name
297 (repo-string "")
298 "The value to show as repository name.")
299 (owner
300 (repo-string "")
301 "A value used to identify the owner of the repository.")
302 (path
303 (repo-string "")
304 "An absolute path to the repository directory.")
305 (readme
306 (repo-string "")
307 "A path (relative to repo) which specifies a file to include verbatim
308 as the \"About\" page for this repo.")
309 (section
310 (repo-string "")
311 "The name of the current repository section - all repositories defined
312 after this option will inherit the current section name.")
313 (extra-options
314 (repo-list '())
315 "Extra options will be appended to cgitrc file."))
316
317 ;; Generate a <cgit-configuration> record, which may include a list of
318 ;; <repository-cgit-configuration>, <nginx-server-configuration>, <package>.
319 (define-configuration cgit-configuration
320 (package
321 (package cgit)
322 "The CGIT package.")
323 (nginx
324 (nginx-server-configuration-list (list %cgit-configuration-nginx))
325 "NGINX configuration.")
326 (about-filter
327 (file-object "")
328 "Specifies a command which will be invoked to format the content of about
329 pages (both top-level and for each repository).")
330 (agefile
331 (string "")
332 "Specifies a path, relative to each repository path, which can be used to
333 specify the date and time of the youngest commit in the repository.")
334 (auth-filter
335 (file-object "")
336 "Specifies a command that will be invoked for authenticating repository
337 access.")
338 (branch-sort
339 (string "name")
340 "Flag which, when set to @samp{age}, enables date ordering in the branch
341 ref list, and when set @samp{name} enables ordering by branch name.")
342 (cache-root
343 (string "/var/cache/cgit")
344 "Path used to store the cgit cache entries.")
345 (cache-static-ttl
346 (integer -1)
347 "Number which specifies the time-to-live, in minutes, for the cached
348 version of repository pages accessed with a fixed SHA1.")
349 (cache-dynamic-ttl
350 (integer 5)
351 "Number which specifies the time-to-live, in minutes, for the cached
352 version of repository pages accessed without a fixed SHA1.")
353 (cache-repo-ttl
354 (integer 5)
355 "Number which specifies the time-to-live, in minutes, for the cached
356 version of the repository summary page.")
357 (cache-root-ttl
358 (integer 5)
359 "Number which specifies the time-to-live, in minutes, for the cached
360 version of the repository index page.")
361 (cache-scanrc-ttl
362 (integer 15)
363 "Number which specifies the time-to-live, in minutes, for the result of
364 scanning a path for Git repositories.")
365 (cache-about-ttl
366 (integer 15)
367 "Number which specifies the time-to-live, in minutes, for the cached
368 version of the repository about page.")
369 (cache-snapshot-ttl
370 (integer 5)
371 "Number which specifies the time-to-live, in minutes, for the cached
372 version of snapshots.")
373 (cache-size
374 (integer 0)
375 "The maximum number of entries in the cgit cache. When set to
376 @samp{0}, caching is disabled.")
377 (case-sensitive-sort?
378 (boolean #t)
379 "Sort items in the repo list case sensitively.")
380 (clone-prefix
381 (list '())
382 "List of common prefixes which, when combined with a repository URL,
383 generates valid clone URLs for the repository.")
384 (clone-url
385 (list '())
386 "List of @code{clone-url} templates.")
387 (commit-filter
388 (file-object "")
389 "Command which will be invoked to format commit messages.")
390 (commit-sort
391 (string "git log")
392 "Flag which, when set to @samp{date}, enables strict date ordering in the
393 commit log, and when set to @samp{topo} enables strict topological
394 ordering.")
395 (css
396 (file-object "/share/cgit/cgit.css")
397 "URL which specifies the css document to include in all cgit pages.")
398 (email-filter
399 (file-object "")
400 "Specifies a command which will be invoked to format names and email
401 address of committers, authors, and taggers, as represented in various
402 places throughout the cgit interface.")
403 (embedded?
404 (boolean #f)
405 "Flag which, when set to @samp{#t}, will make cgit generate a HTML
406 fragment suitable for embedding in other HTML pages.")
407 (enable-commit-graph?
408 (boolean #f)
409 "Flag which, when set to @samp{#t}, will make cgit print an ASCII-art
410 commit history graph to the left of the commit messages in the
411 repository log page.")
412 (enable-filter-overrides?
413 (boolean #f)
414 "Flag which, when set to @samp{#t}, allows all filter settings to be
415 overridden in repository-specific cgitrc files.")
416 (enable-follow-links?
417 (boolean #f)
418 "Flag which, when set to @samp{#t}, allows users to follow a file in the
419 log view.")
420 (enable-http-clone?
421 (boolean #t)
422 "If set to @samp{#t}, cgit will act as an dumb HTTP endpoint for Git
423 clones.")
424 (enable-index-links?
425 (boolean #f)
426 "Flag which, when set to @samp{#t}, will make cgit generate extra links
427 \"summary\", \"commit\", \"tree\" for each repo in the repository index.")
428 (enable-index-owner?
429 (boolean #t)
430 "Flag which, when set to @samp{#t}, will make cgit display the owner of
431 each repo in the repository index.")
432 (enable-log-filecount?
433 (boolean #f)
434 "Flag which, when set to @samp{#t}, will make cgit print the number of
435 modified files for each commit on the repository log page.")
436 (enable-log-linecount?
437 (boolean #f)
438 "Flag which, when set to @samp{#t}, will make cgit print the number of
439 added and removed lines for each commit on the repository log page.")
440 (enable-remote-branches?
441 (boolean #f)
442 "Flag which, when set to @code{#t}, will make cgit display remote
443 branches in the summary and refs views.")
444 (enable-subject-links?
445 (boolean #f)
446 "Flag which, when set to @code{1}, will make cgit use the subject of
447 the parent commit as link text when generating links to parent commits
448 in commit view.")
449 (enable-html-serving?
450 (boolean #f)
451 "Flag which, when set to @samp{#t}, will make cgit use the subject of the
452 parent commit as link text when generating links to parent commits in
453 commit view.")
454 (enable-tree-linenumbers?
455 (boolean #t)
456 "Flag which, when set to @samp{#t}, will make cgit generate linenumber
457 links for plaintext blobs printed in the tree view.")
458 (enable-git-config?
459 (boolean #f)
460 "Flag which, when set to @samp{#f}, will allow cgit to use Git config to
461 set any repo specific settings.")
462 (favicon
463 (file-object "/favicon.ico")
464 "URL used as link to a shortcut icon for cgit.")
465 (footer
466 (string "")
467 "The content of the file specified with this option will be included
468 verbatim at the bottom of all pages (i.e. it replaces the standard
469 \"generated by...\" message).")
470 (head-include
471 (string "")
472 "The content of the file specified with this option will be included
473 verbatim in the HTML HEAD section on all pages.")
474 (header
475 (string "")
476 "The content of the file specified with this option will be included
477 verbatim at the top of all pages.")
478 (include
479 (file-object "")
480 "Name of a configfile to include before the rest of the current config-
481 file is parsed.")
482 (index-header
483 (string "")
484 "The content of the file specified with this option will be included
485 verbatim above the repository index.")
486 (index-info
487 (string "")
488 "The content of the file specified with this option will be included
489 verbatim below the heading on the repository index page.")
490 (local-time?
491 (boolean #f)
492 "Flag which, if set to @samp{#t}, makes cgit print commit and tag times
493 in the servers timezone.")
494 (logo
495 (file-object "/share/cgit/cgit.png")
496 "URL which specifies the source of an image which will be used as a logo
497 on all cgit pages.")
498 (logo-link
499 (string "")
500 "URL loaded when clicking on the cgit logo image.")
501 (owner-filter
502 (file-object "")
503 "Command which will be invoked to format the Owner column of the main
504 page.")
505 (max-atom-items
506 (integer 10)
507 "Number of items to display in atom feeds view.")
508 (max-commit-count
509 (integer 50)
510 "Number of entries to list per page in \"log\" view.")
511 (max-message-length
512 (integer 80)
513 "Number of commit message characters to display in \"log\" view.")
514 (max-repo-count
515 (integer 50)
516 "Specifies the number of entries to list per page on the repository index
517 page.")
518 (max-repodesc-length
519 (integer 80)
520 "Specifies the maximum number of repo description characters to display
521 on the repository index page.")
522 (max-blob-size
523 (integer 0)
524 "Specifies the maximum size of a blob to display HTML for in KBytes.")
525 (max-stats
526 (string "")
527 "Maximum statistics period. Valid values are @samp{week},@samp{month},
528 @samp{quarter} and @samp{year}.")
529 (mimetype
530 (mimetype-alist '((gif "image/gif")
531 (html "text/html")
532 (jpg "image/jpeg")
533 (jpeg "image/jpeg")
534 (pdf "application/pdf")
535 (png "image/png")
536 (svg "image/svg+xml")))
537 "Mimetype for the specified filename extension.")
538 (mimetype-file
539 (file-object "")
540 "Specifies the file to use for automatic mimetype lookup.")
541 (module-link
542 (string "")
543 "Text which will be used as the formatstring for a hyperlink when a
544 submodule is printed in a directory listing.")
545 (nocache?
546 (boolean #f)
547 "If set to the value @samp{#t} caching will be disabled.")
548 (noplainemail?
549 (boolean #f)
550 "If set to @samp{#t} showing full author email addresses will be
551 disabled.")
552 (noheader?
553 (boolean #f)
554 "Flag which, when set to @samp{#t}, will make cgit omit the standard
555 header on all pages.")
556 (project-list
557 (project-list '())
558 "A list of subdirectories inside of @code{repository-directory}, relative
559 to it, that should loaded as Git repositories. An empty list means that all
560 subdirectories will be loaded.")
561 (readme
562 (file-object "")
563 "Text which will be used as default value for @code{cgit-repo-readme}.")
564 (remove-suffix?
565 (boolean #f)
566 "If set to @code{#t} and @code{repository-directory} is enabled, if any
567 repositories are found with a suffix of @code{.git}, this suffix will be
568 removed for the URL and name.")
569 (renamelimit
570 (integer -1)
571 "Maximum number of files to consider when detecting renames.")
572 (repository-sort
573 (string "")
574 "The way in which repositories in each section are sorted.")
575 (robots
576 (robots-list (list "noindex" "nofollow"))
577 "Text used as content for the @code{robots} meta-tag.")
578 (root-desc
579 (string "a fast webinterface for the git dscm")
580 "Text printed below the heading on the repository index page.")
581 (root-readme
582 (string "")
583 "The content of the file specified with this option will be included
584 verbatim below thef \"about\" link on the repository index page.")
585 (root-title
586 (string "")
587 "Text printed as heading on the repository index page.")
588 (scan-hidden-path
589 (boolean #f)
590 "If set to @samp{#t} and repository-directory is enabled,
591 repository-directory will recurse into directories whose name starts with a
592 period. Otherwise, repository-directory will stay away from such directories,
593 considered as \"hidden\". Note that this does not apply to the \".git\"
594 directory in non-bare repos.")
595 (snapshots
596 (list '())
597 "Text which specifies the default set of snapshot formats that cgit
598 generates links for.")
599 (repository-directory
600 (repository-directory "/srv/git")
601 "Name of the directory to scan for repositories (represents
602 @code{scan-path}).")
603 (section
604 (string "")
605 "The name of the current repository section - all repositories defined
606 after this option will inherit the current section name.")
607 (section-sort
608 (string "")
609 "Flag which, when set to @samp{1}, will sort the sections on the repository
610 listing by name.")
611 (section-from-path
612 (integer 0)
613 "A number which, if defined prior to repository-directory, specifies how
614 many path elements from each repo path to use as a default section name.")
615 (side-by-side-diffs?
616 (boolean #f)
617 "If set to @samp{#t} shows side-by-side diffs instead of unidiffs per
618 default.")
619 (source-filter
620 (file-object "")
621 "Specifies a command which will be invoked to format plaintext blobs in the
622 tree view.")
623 (summary-branches
624 (integer 10)
625 "Specifies the number of branches to display in the repository \"summary\"
626 view.")
627 (summary-log
628 (integer 10)
629 "Specifies the number of log entries to display in the repository
630 \"summary\" view.")
631 (summary-tags
632 (integer 10)
633 "Specifies the number of tags to display in the repository \"summary\"
634 view.")
635 (strict-export
636 (string "")
637 "Filename which, if specified, needs to be present within the repository
638 for cgit to allow access to that repository.")
639 (virtual-root
640 (string "/")
641 "URL which, if specified, will be used as root for all cgit links.")
642 (repositories
643 (repository-cgit-configuration-list '())
644 "A list of @dfn{cgit-repo} records to use with config.")
645 (extra-options
646 (list '())
647 "Extra options will be appended to cgitrc file."))
648
649 ;; This distinguishes fields whose order matters, and makes sure further
650 ;; changes won't inadvertently change the order.
651 (define (serialize-cgit-configuration config)
652 (define (rest? field)
653 (not (memq (configuration-field-name field)
654 '(project-list
655 extra-options
656 repository-directory
657 repositories))))
658 #~(string-append
659 #$(let ((rest (filter rest? cgit-configuration-fields)))
660 (serialize-configuration config rest))
661 #$(serialize-project-list
662 'project-list
663 (cgit-configuration-project-list config))
664 #$(serialize-extra-options
665 (cgit-configuration-extra-options config))
666 #$(serialize-repository-directory
667 'repository-directory
668 (cgit-configuration-repository-directory config))
669 #$(serialize-repository-cgit-configuration-list
670 'repositories
671 (cgit-configuration-repositories config))))
672
673 (define-configuration opaque-cgit-configuration
674 (cgit
675 (package cgit)
676 "The cgit package.")
677 (cgitrc
678 (string (configuration-missing-field 'opaque-cgit-configuration 'cgitrc))
679 "The contents of the @code{cgitrc} to use.")
680 (cache-root
681 (string "/var/cache/cgit")
682 "Path used to store the cgit cache entries.")
683 (nginx
684 (nginx-server-configuration-list (list %cgit-configuration-nginx))
685 "NGINX configuration."))
686
687 (define (cgit-activation config)
688 "Return the activation gexp for CONFIG."
689 (let* ((opaque-config? (opaque-cgit-configuration? config))
690 (config-str
691 (if opaque-config?
692 (opaque-cgit-configuration-cgitrc config)
693 (serialize-cgit-configuration config))))
694 #~(begin
695 (use-modules (guix build utils))
696 (mkdir-p #$(if opaque-config?
697 (opaque-cgit-configuration-cache-root config)
698 (cgit-configuration-cache-root config)))
699 (copy-file #$(mixed-text-file "cgitrc" config-str)
700 "/etc/cgitrc"))))
701
702 (define (cgit-configuration-nginx-config config)
703 (if (opaque-cgit-configuration? config)
704 (opaque-cgit-configuration-nginx config)
705 (cgit-configuration-nginx config)))
706
707 (define cgit-service-type
708 (service-type
709 (name 'cgit)
710 (extensions
711 (list (service-extension activation-service-type
712 cgit-activation)
713 (service-extension nginx-service-type
714 cgit-configuration-nginx-config)
715
716 ;; Make sure fcgiwrap is instantiated.
717 (service-extension fcgiwrap-service-type
718 (const #t))))
719 (default-value (cgit-configuration))
720 (description
721 "Run the cgit web interface, which allows users to browse Git
722 repositories.")))
723
724 (define (generate-cgit-documentation)
725 (generate-documentation
726 `((cgit-configuration
727 ,cgit-configuration-fields
728 (repositories repository-cgit-configuration))
729 (repository-cgit-configuration
730 ,repository-cgit-configuration-fields))
731 'cgit-configuration))