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