From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59260) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1egj3F-0001ur-1h for guix-patches@gnu.org; Tue, 30 Jan 2018 22:27:14 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1egj38-0005f6-Vg for guix-patches@gnu.org; Tue, 30 Jan 2018 22:27:09 -0500 Received: from debbugs.gnu.org ([208.118.235.43]:42179) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1egj38-0005eO-Fu for guix-patches@gnu.org; Tue, 30 Jan 2018 22:27:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1egj38-0003LW-27 for guix-patches@gnu.org; Tue, 30 Jan 2018 22:27:02 -0500 Subject: [bug#29820] [PATCH] services: cgit: Add more configuration fields. In-Reply-To: <87incy9yv6.fsf@gmail.com> Resent-Message-ID: From: Oleg Pykhalov References: <87incy9yv6.fsf@gmail.com> <87h8sdb6qa.fsf@lassieur.org> <87po6yu7h9.fsf@gmail.com> <871sjdz8ca.fsf@lassieur.org> Date: Wed, 31 Jan 2018 06:26:10 +0300 Message-ID: <87r2q6zp2l.fsf@gmail.com> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="==-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+kyle=kyleam.com@gnu.org Sender: "Guix-patches" To: =?UTF-8?Q?Cl=C3=A9ment?= Lassieur Cc: 29820@debbugs.gnu.org --==-=-= Content-Type: multipart/mixed; boundary="=-=-=" --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hello Cl=C3=A9ment, apologies for such a long pause. I tried to implement all we talked about, but I kinda stuck. What do you think about merging and not hold it more for a small issue with project-list? The patch is attached. The test suite succeeds: =2D-8<---------------cut here---------------start------------->8--- ./pre-inst-env env GUIX_PACKAGE_PATH=3D make check-system TESTS=3Dcgit =2D-8<---------------cut here---------------end--------------->8--- Cl=C3=A9ment Lassieur writes: [...] > If you stick with depending on the fields order, then could you add > very clear comments so that people don't add fields at the wrong > place? WDYT? I think we could stick with ordering fields and comments. I'll add a note commentary about order at the head of the file. >>> I think the official project uses 'cgit' instead of 'Cgit' (there are >>> other occurrences where you use 'Cgit'). >> >> Ludovic asked to capitalize cgit in >> https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D28283#14 > > But he was only talking about titles wasn't he? I think not only, because we have Cgit everywhere in the current documentation. >>>> + (repository-directory >>>> + (repository-directory "/srv/git") >>>> + "Name of the directory to scan for repositories.") >>> >>> I believe it would be clearer if it was named the same way cgit names >>> it: scan-path. >> >> Ludovic asked to rename it in >> https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D28283#14 >> >> I don't know should we stay close to cgit naming conventions or not. >> Thoughts? > > At least it should be possible to grep 'scan_path' in the documentation, > so that users can easily find what to use instead of 'scan-path'. Could > you say 'scan_path' is the original name in the docstring? Good idea, thank you! I'll add a '(represents @code{scan-path})' to the description of the 'repository-directory' field. >>>> + (project-list >>>> + (list '()) >>>> + "A list of subdirectories inside of @code{repository-directory}, r= elative >>>> +to it, that should loaded as Git repositories.") >>> >>> I forgot one thing: 'project-list' is a file, not a list of strings. I >>> agree it's weird that cgit's documentation doesn't say it's a file. I >>> see two solutions: >> >> Sorry, it's not clear for me. As I understand from CGITRC(5) it's a >> list like: >> >> project-list=3D/share/cgit/cgit.png /share/cgit/cgit.jpg >> >> relative to /srv/git (in our case). > > CGITRC isn't clear. It's really a file containing the list of git > directories. For example: > > /etc/cgit/project-list: > > a/b/foo.git > c/bar.git > baz.git > > And > > project-list=3D/etc/cgit/project-list > >>> 1. Change the type to 'string', so that people can set a file name. >>> >>> 2. Use a list type that would transparently transform its values into a >>> file in the store, with the generated cgitrc file pointing to it. >>> >>> The second solution is better because the user won't need to create the >>> file. >> >> I choose 1st for now, because 2nd I don't understand what need to be >> produced at the end. Could you give me an example? > > With 2nd, users would write a configuration like > > (project-list '("a/b/foo.git" > "c/bar.git" > "baz.git")) > > And 'guix system reconfigure' would create the file > /gnu/store/xxxxxxx-project-list containing those three lines. The > generated cgitrc file would contain: > > project-list=3D/gnu/store/xxxxxxx-project-list > > You could use a type whose serializer would call the 'plain-file' > procedure. Will be in a TODO list until I get more familiar with Guix or somebody else add this. >>> Also, could you add a way to use an opaque configuration file? It would >>> be helpful for users who don't have time to update their configuration, >>> or in case there are new cgit configurations that are not yet >>> implemented by the Scheme service. >> >> Sure. >> >> Is the following order is OK? >> >> (serialize-configuration >> (cgit-configuration >> (extra-options (list "soo=3Ddo")) >> (repositories (list >> (repository-cgit-configuration >> (module-link-path '("/super/cow" "moo")) >> (extra-options (list "goo=3Dfoo")))))) >> cgit-configuration-fields) >> >> =E2=80=A6 >> repo.extra-options=3Dgoo=3Dfoo >> extra-options=3Dsoo=3Ddo >> # END OF FILE > > I was more thinking about something like in the Dovecot service where > you can pass the whole file as a string. OK, thank you for a reference to Dovecot example. I'll add this. >> Also I need to mention that this patch probably will broke system >> reconfigure and require update /etc/config.scm. > > Yes, of course :-) OK. --=-=-= Content-Type: text/x-patch; charset=utf-8 Content-Disposition: attachment; filename=0001-services-cgit-Add-more-configuration-fields.patch Content-Transfer-Encoding: quoted-printable Content-Description: [PATCH] services: cgit: Add more configuration fields. From=20c20ee2cd72343732904f89eb6d46ca6ce7eacb27 Mon Sep 17 00:00:00 2001 From: Oleg Pykhalov Date: Tue, 12 Dec 2017 02:13:55 +0300 Subject: [PATCH] services: cgit: Add more configuration fields. * gnu/services/version-control.scm (cgit-service-type): Move to separate fi= le. * gnu/services/cgit.scm: New file. * gnu/local.mk (GNU_SYSTEM_MODULES): Add this. * gnu/tests/version-control.scm: Add this. * doc/guix.texi (Cgit Service): Document this. =2D-- doc/guix.texi | 953 +++++++++++++++++++++++++++++++++++= ++-- gnu/local.mk | 1 + gnu/services/cgit.scm | 683 ++++++++++++++++++++++++++++ gnu/services/version-control.scm | 121 ----- gnu/tests/version-control.scm | 3 +- 5 files changed, 1605 insertions(+), 156 deletions(-) create mode 100644 gnu/services/cgit.scm diff --git a/doc/guix.texi b/doc/guix.texi index 2b27a675c..9ac967093 100644 =2D-- a/doc/guix.texi +++ b/doc/guix.texi @@ -45,7 +45,8 @@ Copyright @copyright{} 2017 George Clemmer@* Copyright @copyright{} 2017 Andy Wingo@* Copyright @copyright{} 2017 Arun Isaac@* Copyright @copyright{} 2017 nee@* =2DCopyright @copyright{} 2018 Rutger Helling +Copyright @copyright{} 2018 Rutger Helling@* +Copyright @copyright{} 2018 Oleg Pykhalov =20 Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or @@ -18276,54 +18277,938 @@ By default, Cgit can be accessed on port 80 (@co= de{http://localhost:80}). (service cgit-service-type) @end example =20 =2D@deftp {Data Type} cgit-configuration =2DData type representing the configuration of Cgit. =2DThis type has the following parameters: +@c %start of fragment =20 =2D@table @asis =2D@item @code{config-file} (default: @code{(cgit-configuration-file)}) =2DThe configuration file to use for Cgit. This can be set to a =2D@dfn{cgit-configuration-file} record value, or any gexp =2D(@pxref{G-Expressions}). +Available @code{cgit-configuration} fields are: =20 =2DFor example, to instead use a local file, the @code{local-file} function =2Dcan be used: +@deftypevr {@code{cgit-configuration} parameter} package package +The CGIT package. =20 =2D@example =2D(service cgit-service-type =2D (cgit-configuration =2D (config-file (local-file "./my-cgitrc.conf")))) =2D@end example +@end deftypevr =20 =2D@item @code{package} (default: @code{cgit}) =2DThe Cgit package to use. +@deftypevr {@code{cgit-configuration} parameter} nginx-server-configuratio= n-list nginx +NGINX configuration. =20 =2D@end table =2D@end deftp +@end deftypevr =20 =2D@deftp {Data Type} cgit-configuration-file =2DData type representing the configuration options for Cgit. =2DThis type has the following parameters: +@deftypevr {@code{cgit-configuration} parameter} string about-filter +Specifies a command which will be invoked to format the content of about +pages (both top-level and for each repository). =20 =2D@table @asis =2D@item @code{css} (default: @code{"/share/cgit/cgit.css"}) +Defaults to @samp{""}. + +@end deftypevr + +@deftypevr {@code{cgit-configuration} parameter} string agefile +Specifies a path, relative to each repository path, which can be used to +specify the date and time of the youngest commit in the repository. + +Defaults to @samp{""}. + +@end deftypevr + +@deftypevr {@code{cgit-configuration} parameter} string auth-filter +Specifies a command that will be invoked for authenticating repository +access. + +Defaults to @samp{""}. + +@end deftypevr + +@deftypevr {@code{cgit-configuration} parameter} string branch-sort +Flag which, when set to @samp{age}, enables date ordering in the branch +ref list, and when set @samp{name} enables ordering by branch name. + +Defaults to @samp{"name"}. + +@end deftypevr + +@deftypevr {@code{cgit-configuration} parameter} string cache-root +Path used to store the Cgit cache entries. + +Defaults to @samp{"/var/cache/cgit"}. + +@end deftypevr + +@deftypevr {@code{cgit-configuration} parameter} integer cache-static-ttl +Number which specifies the time-to-live, in minutes, for the cached +version of repository pages accessed with a fixed SHA1. + +Defaults to @samp{-1}. + +@end deftypevr + +@deftypevr {@code{cgit-configuration} parameter} integer cache-dynamic-ttl +Number which specifies the time-to-live, in minutes, for the cached +version of repository pages accessed without a fixed SHA1. + +Defaults to @samp{5}. + +@end deftypevr + +@deftypevr {@code{cgit-configuration} parameter} integer cache-repo-ttl +Number which specifies the time-to-live, in minutes, for the cached +version of the repository summary page. + +Defaults to @samp{5}. + +@end deftypevr + +@deftypevr {@code{cgit-configuration} parameter} integer cache-root-ttl +Number which specifies the time-to-live, in minutes, for the cached +version of the repository index page. + +Defaults to @samp{5}. + +@end deftypevr + +@deftypevr {@code{cgit-configuration} parameter} integer cache-scanrc-ttl +Number which specifies the time-to-live, in minutes, for the result of +scanning a path for Git repositories. + +Defaults to @samp{15}. + +@end deftypevr + +@deftypevr {@code{cgit-configuration} parameter} integer cache-about-ttl +Number which specifies the time-to-live, in minutes, for the cached +version of the repository about page. + +Defaults to @samp{15}. + +@end deftypevr + +@deftypevr {@code{cgit-configuration} parameter} integer cache-snapshot-ttl +Number which specifies the time-to-live, in minutes, for the cached +version of snapshots. + +Defaults to @samp{5}. + +@end deftypevr + +@deftypevr {@code{cgit-configuration} parameter} integer cache-size +The maximum number of entries in the cgit cache. When set to @samp{0}, +caching is disabled. + +Defaults to @samp{0}. + +@end deftypevr + +@deftypevr {@code{cgit-configuration} parameter} boolean case-sensitive-so= rt? +Sort items in the repo list case sensitively. + +Defaults to @samp{#t}. + +@end deftypevr + +@deftypevr {@code{cgit-configuration} parameter} list clone-prefix +List of common prefixes which, when combined with a repository URL, +generates valid clone URLs for the repository. + +Defaults to @samp{()}. + +@end deftypevr + +@deftypevr {@code{cgit-configuration} parameter} list clone-url +List of @code{clone-url} templates. + +Defaults to @samp{()}. + +@end deftypevr + +@deftypevr {@code{cgit-configuration} parameter} string commit-filter +Command which will be invoked to format commit messages. + +Defaults to @samp{""}. + +@end deftypevr + +@deftypevr {@code{cgit-configuration} parameter} string commit-sort +Flag which, when set to @samp{date}, enables strict date ordering in the +commit log, and when set to @samp{topo} enables strict topological +ordering. + +Defaults to @samp{"git log"}. + +@end deftypevr + +@deftypevr {@code{cgit-configuration} parameter} string css URL which specifies the css document to include in all Cgit pages. =20 =2D@item @code{logo} (default: @code{"/share/cgit/cgit.png"}) +Defaults to @samp{"/share/cgit/cgit.css"}. + +@end deftypevr + +@deftypevr {@code{cgit-configuration} parameter} string email-filter +Specifies a command which will be invoked to format names and email +address of committers, authors, and taggers, as represented in various +places throughout the Cgit interface. + +Defaults to @samp{""}. + +@end deftypevr + +@deftypevr {@code{cgit-configuration} parameter} boolean embedded? +Flag which, when set to @samp{#t}, will make Cgit generate a HTML +fragment suitable for embedding in other HTML pages. + +Defaults to @samp{#f}. + +@end deftypevr + +@deftypevr {@code{cgit-configuration} parameter} boolean enable-commit-gra= ph? +Flag which, when set to @samp{#t}, will make Cgit print an ASCII-art +commit history graph to the left of the commit messages in the +repository log page. + +Defaults to @samp{#f}. + +@end deftypevr + +@deftypevr {@code{cgit-configuration} parameter} boolean enable-filter-ove= rrides? +Flag which, when set to @samp{#t}, allows all filter settings to be +overridden in repository-specific cgitrc files. + +Defaults to @samp{#f}. + +@end deftypevr + +@deftypevr {@code{cgit-configuration} parameter} boolean enable-follow-lin= ks? +Flag which, when set to @samp{#t}, allows users to follow a file in the +log view. + +Defaults to @samp{#f}. + +@end deftypevr + +@deftypevr {@code{cgit-configuration} parameter} boolean enable-http-clone? +If set to @samp{#t}, Cgit will act as an dumb HTTP endpoint for Git +clones. + +Defaults to @samp{#t}. + +@end deftypevr + +@deftypevr {@code{cgit-configuration} parameter} boolean enable-index-link= s? +Flag which, when set to @samp{#t}, will make Cgit generate extra links +"summary", "commit", "tree" for each repo in the repository index. + +Defaults to @samp{#f}. + +@end deftypevr + +@deftypevr {@code{cgit-configuration} parameter} boolean enable-index-owne= r? +Flag which, when set to @samp{#t}, will make Cgit display the owner of +each repo in the repository index. + +Defaults to @samp{#t}. + +@end deftypevr + +@deftypevr {@code{cgit-configuration} parameter} boolean enable-log-fileco= unt? +Flag which, when set to @samp{#t}, will make Cgit print the number of +modified files for each commit on the repository log page. + +Defaults to @samp{#f}. + +@end deftypevr + +@deftypevr {@code{cgit-configuration} parameter} boolean enable-log-lineco= unt? +Flag which, when set to @samp{#t}, will make Cgit print the number of +added and removed lines for each commit on the repository log page. + +Defaults to @samp{#f}. + +@end deftypevr + +@deftypevr {@code{cgit-configuration} parameter} boolean enable-remote-bra= nches? +Flag which, when set to @code{#t}, will make Cgit display remote +branches in the summary and refs views. + +Defaults to @samp{#f}. + +@end deftypevr + +@deftypevr {@code{cgit-configuration} parameter} boolean enable-subject-li= nks? +Flag which, when set to @code{1}, will make Cgit use the subject of the +parent commit as link text when generating links to parent commits in +commit view. + +Defaults to @samp{#f}. + +@end deftypevr + +@deftypevr {@code{cgit-configuration} parameter} boolean enable-html-servi= ng? +Flag which, when set to @samp{#t}, will make Cgit use the subject of the +parent commit as link text when generating links to parent commits in +commit view. + +Defaults to @samp{#f}. + +@end deftypevr + +@deftypevr {@code{cgit-configuration} parameter} boolean enable-tree-linen= umbers? +Flag which, when set to @samp{#t}, will make Cgit generate linenumber +links for plaintext blobs printed in the tree view. + +Defaults to @samp{#t}. + +@end deftypevr + +@deftypevr {@code{cgit-configuration} parameter} boolean enable-git-config? +Flag which, when set to @samp{#f}, will allow Cgit to use Git config to +set any repo specific settings. + +Defaults to @samp{#f}. + +@end deftypevr + +@deftypevr {@code{cgit-configuration} parameter} string favicon +URL used as link to a shortcut icon for Cgit. + +Defaults to @samp{"/favicon.ico"}. + +@end deftypevr + +@deftypevr {@code{cgit-configuration} parameter} string footer +The content of the file specified with this option will be included +verbatim at the bottom of all pages (i.e. it replaces the standard +"generated by..." message). + +Defaults to @samp{""}. + +@end deftypevr + +@deftypevr {@code{cgit-configuration} parameter} string head-include +The content of the file specified with this option will be included +verbatim in the HTML HEAD section on all pages. + +Defaults to @samp{""}. + +@end deftypevr + +@deftypevr {@code{cgit-configuration} parameter} string header +The content of the file specified with this option will be included +verbatim at the top of all pages. + +Defaults to @samp{""}. + +@end deftypevr + +@deftypevr {@code{cgit-configuration} parameter} string include +Name of a configfile to include before the rest of the current config- +file is parsed. + +Defaults to @samp{""}. + +@end deftypevr + +@deftypevr {@code{cgit-configuration} parameter} string index-header +The content of the file specified with this option will be included +verbatim above the repository index. + +Defaults to @samp{""}. + +@end deftypevr + +@deftypevr {@code{cgit-configuration} parameter} string index-info +The content of the file specified with this option will be included +verbatim below the heading on the repository index page. + +Defaults to @samp{""}. + +@end deftypevr + +@deftypevr {@code{cgit-configuration} parameter} boolean local-time? +Flag which, if set to @samp{#t}, makes Cgit print commit and tag times +in the servers timezone. + +Defaults to @samp{#f}. + +@end deftypevr + +@deftypevr {@code{cgit-configuration} parameter} string logo URL which specifies the source of an image which will be used as a logo on all Cgit pages. =20 =2D@item @code{virtual-root} (default: @code{"/"}) =2DURL which, if specified, will be used as root for all Cgit links. +Defaults to @samp{"/share/cgit/cgit.png"}. =20 =2D@item @code{repository-directory} (default: @code{"/srv/git"}) =2DName of the directory to scan for repositories. +@end deftypevr =20 =2D@item @code{robots} (default: @code{(list "noindex" "nofollow")}) =2DText used as content for the ``robots'' meta-tag. +@deftypevr {@code{cgit-configuration} parameter} string logo-link +URL loaded when clicking on the Cgit logo image. =20 =2D@end table =2D@end deftp +Defaults to @samp{""}. + +@end deftypevr + +@deftypevr {@code{cgit-configuration} parameter} string owner-filter +Command which will be invoked to format the Owner column of the main +page. + +Defaults to @samp{""}. + +@end deftypevr + +@deftypevr {@code{cgit-configuration} parameter} integer max-atom-items +Number of items to display in atom feeds view. + +Defaults to @samp{10}. + +@end deftypevr + +@deftypevr {@code{cgit-configuration} parameter} integer max-commit-count +Number of entries to list per page in "log" view. + +Defaults to @samp{50}. + +@end deftypevr + +@deftypevr {@code{cgit-configuration} parameter} integer max-message-length +Number of commit message characters to display in "log" view. + +Defaults to @samp{80}. + +@end deftypevr + +@deftypevr {@code{cgit-configuration} parameter} integer max-repo-count +Specifies the number of entries to list per page on the repository index +page. + +Defaults to @samp{50}. + +@end deftypevr + +@deftypevr {@code{cgit-configuration} parameter} integer max-repodesc-leng= th +Specifies the maximum number of repo description characters to display +on the repository index page. + +Defaults to @samp{80}. + +@end deftypevr + +@deftypevr {@code{cgit-configuration} parameter} integer max-blob-size +Specifies the maximum size of a blob to display HTML for in KBytes. + +Defaults to @samp{0}. + +@end deftypevr + +@deftypevr {@code{cgit-configuration} parameter} string max-stats +Maximum statistics period. Valid values are @samp{week},@samp{month}, +@samp{quarter} and @samp{year}. + +Defaults to @samp{""}. + +@end deftypevr + +@deftypevr {@code{cgit-configuration} parameter} mimetype-alist mimetype +Mimetype for the specified filename extension. + +Defaults to @samp{((gif "image/gif") (html "text/html") (jpg +"image/jpeg") (jpeg "image/jpeg") (pdf "application/pdf") (png +"image/png") (svg "image/svg+xml"))}. + +@end deftypevr + +@deftypevr {@code{cgit-configuration} parameter} string mimetype-file +Specifies the file to use for automatic mimetype lookup. + +Defaults to @samp{""}. + +@end deftypevr + +@deftypevr {@code{cgit-configuration} parameter} string module-link +Text which will be used as the formatstring for a hyperlink when a +submodule is printed in a directory listing. + +Defaults to @samp{""}. + +@end deftypevr + +@deftypevr {@code{cgit-configuration} parameter} boolean nocache? +If set to the value @samp{#t} caching will be disabled. + +Defaults to @samp{#f}. + +@end deftypevr + +@deftypevr {@code{cgit-configuration} parameter} boolean noplainemail? +If set to @samp{#t} showing full author email addresses will be +disabled. + +Defaults to @samp{#f}. + +@end deftypevr + +@deftypevr {@code{cgit-configuration} parameter} boolean noheader? +Flag which, when set to @samp{#t}, will make Cgit omit the standard +header on all pages. + +Defaults to @samp{#f}. + +@end deftypevr + +@deftypevr {@code{cgit-configuration} parameter} string project-list +A list of subdirectories inside of @code{repository-directory}, relative +to it, that should loaded as Git repositories. + +Defaults to @samp{""}. + +@end deftypevr + +@deftypevr {@code{cgit-configuration} parameter} string readme +Text which will be used as default value for @code{cgit-repo-readme}. + +Defaults to @samp{""}. + +@end deftypevr + +@deftypevr {@code{cgit-configuration} parameter} boolean remove-suffix? +If set to @code{#t} and @code{repository-directory} is enabled, if any +repositories are found with a suffix of @code{.git}, this suffix will be +removed for the URL and name. + +Defaults to @samp{#f}. + +@end deftypevr + +@deftypevr {@code{cgit-configuration} parameter} integer renamelimit +Maximum number of files to consider when detecting renames. + +Defaults to @samp{-1}. + +@end deftypevr + +@deftypevr {@code{cgit-configuration} parameter} string repository-sort +The way in which repositories in each section are sorted. + +Defaults to @samp{""}. + +@end deftypevr + +@deftypevr {@code{cgit-configuration} parameter} robots-list robots +Text used as content for the @code{robots} meta-tag. + +Defaults to @samp{("noindex" "nofollow")}. + +@end deftypevr + +@deftypevr {@code{cgit-configuration} parameter} string root-desc +Text printed below the heading on the repository index page. + +Defaults to @samp{"a fast webinterface for the git dscm"}. + +@end deftypevr + +@deftypevr {@code{cgit-configuration} parameter} string root-readme +The content of the file specified with this option will be included +verbatim below thef "about" link on the repository index page. + +Defaults to @samp{""}. + +@end deftypevr + +@deftypevr {@code{cgit-configuration} parameter} string root-title +Text printed as heading on the repository index page. + +Defaults to @samp{""}. + +@end deftypevr + +@deftypevr {@code{cgit-configuration} parameter} boolean scan-hidden-path +If set to @samp{#t} and repository-directory is enabled, +repository-directory will recurse into directories whose name starts +with a period. Otherwise, repository-directory will stay away from such +directories, considered as "hidden". Note that this does not apply to +the ".git" directory in non-bare repos. + +Defaults to @samp{#f}. + +@end deftypevr + +@deftypevr {@code{cgit-configuration} parameter} list snapshots +Text which specifies the default set of snapshot formats that cgit +generates links for. + +Defaults to @samp{()}. + +@end deftypevr + +@deftypevr {@code{cgit-configuration} parameter} repository-directory repo= sitory-directory +Name of the directory to scan for repositories (represents +@code{scan-path}). + +Defaults to @samp{"/srv/git"}. + +@end deftypevr + +@deftypevr {@code{cgit-configuration} parameter} string section +The name of the current repository section - all repositories defined +after this option will inherit the current section name. + +Defaults to @samp{""}. + +@end deftypevr + +@deftypevr {@code{cgit-configuration} parameter} string section-sort +Flag which, when set to @samp{1}, will sort the sections on the +repository listing by name. + +Defaults to @samp{""}. + +@end deftypevr + +@deftypevr {@code{cgit-configuration} parameter} integer section-from-path +A number which, if defined prior to repository-directory, specifies how +many path elements from each repo path to use as a default section name. + +Defaults to @samp{0}. + +@end deftypevr + +@deftypevr {@code{cgit-configuration} parameter} boolean side-by-side-diff= s? +If set to @samp{#t} shows side-by-side diffs instead of unidiffs per +default. + +Defaults to @samp{#f}. + +@end deftypevr + +@deftypevr {@code{cgit-configuration} parameter} string source-filter +Specifies a command which will be invoked to format plaintext blobs in +the tree view. + +Defaults to @samp{""}. + +@end deftypevr + +@deftypevr {@code{cgit-configuration} parameter} integer summary-branches +Specifies the number of branches to display in the repository "summary" +view. + +Defaults to @samp{10}. + +@end deftypevr + +@deftypevr {@code{cgit-configuration} parameter} integer summary-log +Specifies the number of log entries to display in the repository +"summary" view. + +Defaults to @samp{10}. + +@end deftypevr + +@deftypevr {@code{cgit-configuration} parameter} integer summary-tags +Specifies the number of tags to display in the repository "summary" +view. + +Defaults to @samp{10}. + +@end deftypevr + +@deftypevr {@code{cgit-configuration} parameter} string strict-export +Filename which, if specified, needs to be present within the repository +for Cgit to allow access to that repository. + +Defaults to @samp{""}. + +@end deftypevr + +@deftypevr {@code{cgit-configuration} parameter} string virtual-root +URL which, if specified, will be used as root for all Cgit links. + +Defaults to @samp{"/"}. + +@end deftypevr + +@deftypevr {@code{cgit-configuration} parameter} repository-cgit-configura= tion-list repositories +A list of @dfn{cgit-repo} records to use with config. + +Defaults to @samp{()}. + +Available @code{repository-cgit-configuration} fields are: + +@deftypevr {@code{repository-cgit-configuration} parameter} repo-list snap= shots +A mask of snapshot formats for this repo that cgit generates links for, +restricted by the global @code{snapshots} setting. + +Defaults to @samp{()}. + +@end deftypevr + +@deftypevr {@code{repository-cgit-configuration} parameter} repo-string so= urce-filter +Override the default @code{source-filter}. + +Defaults to @samp{""}. + +@end deftypevr + +@deftypevr {@code{repository-cgit-configuration} parameter} repo-string url +The relative URL used to access the repository. + +Defaults to @samp{""}. + +@end deftypevr + +@deftypevr {@code{repository-cgit-configuration} parameter} repo-string ab= out-filter +Override the default @code{about-filter}. + +Defaults to @samp{""}. + +@end deftypevr + +@deftypevr {@code{repository-cgit-configuration} parameter} repo-string br= anch-sort +Flag which, when set to @samp{age}, enables date ordering in the branch +ref list, and when set to @samp{name} enables ordering by branch name. + +Defaults to @samp{""}. + +@end deftypevr + +@deftypevr {@code{repository-cgit-configuration} parameter} repo-list clon= e-url +A list of URLs which can be used to clone repo. + +Defaults to @samp{()}. + +@end deftypevr + +@deftypevr {@code{repository-cgit-configuration} parameter} repo-string co= mmit-filter +Override the default @code{commit-filter}. + +Defaults to @samp{""}. + +@end deftypevr + +@deftypevr {@code{repository-cgit-configuration} parameter} repo-string co= mmit-sort +Flag which, when set to @samp{date}, enables strict date ordering in the +commit log, and when set to @samp{topo} enables strict topological +ordering. + +Defaults to @samp{""}. + +@end deftypevr + +@deftypevr {@code{repository-cgit-configuration} parameter} repo-string de= fbranch +The name of the default branch for this repository. If no such branch +exists in the repository, the first branch name (when sorted) is used as +default instead. By default branch pointed to by HEAD, or "master" if +there is no suitable HEAD. + +Defaults to @samp{""}. + +@end deftypevr + +@deftypevr {@code{repository-cgit-configuration} parameter} repo-string de= sc +The value to show as repository description. + +Defaults to @samp{""}. + +@end deftypevr + +@deftypevr {@code{repository-cgit-configuration} parameter} repo-string ho= mepage +The value to show as repository homepage. + +Defaults to @samp{""}. + +@end deftypevr + +@deftypevr {@code{repository-cgit-configuration} parameter} repo-string em= ail-filter +Override the default @code{email-filter}. + +Defaults to @samp{""}. + +@end deftypevr + +@deftypevr {@code{repository-cgit-configuration} parameter} repo-boolean e= nable-commit-graph? +A flag which can be used to disable the global setting +@code{enable-commit-graph?}. + +Defaults to @samp{#f}. + +@end deftypevr + +@deftypevr {@code{repository-cgit-configuration} parameter} repo-boolean e= nable-log-filecount? +A flag which can be used to disable the global setting +@code{enable-log-filecount?}. + +Defaults to @samp{#f}. + +@end deftypevr + +@deftypevr {@code{repository-cgit-configuration} parameter} repo-boolean e= nable-log-linecount? +A flag which can be used to disable the global setting +@code{enable-log-linecount?}. + +Defaults to @samp{#f}. + +@end deftypevr + +@deftypevr {@code{repository-cgit-configuration} parameter} repo-boolean e= nable-remote-branches? +Flag which, when set to @code{#t}, will make Cgit display remote +branches in the summary and refs views. + +Defaults to @samp{#f}. + +@end deftypevr + +@deftypevr {@code{repository-cgit-configuration} parameter} repo-boolean e= nable-subject-links? +A flag which can be used to override the global setting +@code{enable-subject-links?}. + +Defaults to @samp{#f}. + +@end deftypevr + +@deftypevr {@code{repository-cgit-configuration} parameter} repo-boolean e= nable-html-serving? +A flag which can be used to override the global setting +@code{enable-html-serving?}. + +Defaults to @samp{#f}. + +@end deftypevr + +@deftypevr {@code{repository-cgit-configuration} parameter} repo-boolean h= ide? +Flag which, when set to @code{#t}, hides the repository from the +repository index. + +Defaults to @samp{#f}. + +@end deftypevr + +@deftypevr {@code{repository-cgit-configuration} parameter} repo-boolean i= gnore? +Flag which, when set to @samp{#t}, ignores the repository. + +Defaults to @samp{#f}. + +@end deftypevr + +@deftypevr {@code{repository-cgit-configuration} parameter} repo-string lo= go +URL which specifies the source of an image which will be used as a logo +on this repo=E2=80=99s pages. + +Defaults to @samp{""}. + +@end deftypevr + +@deftypevr {@code{repository-cgit-configuration} parameter} repo-string lo= go-link +URL loaded when clicking on the Cgit logo image. + +Defaults to @samp{""}. + +@end deftypevr + +@deftypevr {@code{repository-cgit-configuration} parameter} repo-string ow= ner-filter +Override the default @code{owner-filter}. + +Defaults to @samp{""}. + +@end deftypevr + +@deftypevr {@code{repository-cgit-configuration} parameter} repo-string mo= dule-link +Text which will be used as the formatstring for a hyperlink when a +submodule is printed in a directory listing. The arguments for the +formatstring are the path and SHA1 of the submodule commit. + +Defaults to @samp{""}. + +@end deftypevr + +@deftypevr {@code{repository-cgit-configuration} parameter} module-link-pa= th module-link-path +Text which will be used as the formatstring for a hyperlink when a +submodule with the specified subdirectory path is printed in a directory +listing. + +Defaults to @samp{()}. + +@end deftypevr + +@deftypevr {@code{repository-cgit-configuration} parameter} repo-string ma= x-stats +Override the default maximum statistics period. + +Defaults to @samp{""}. + +@end deftypevr + +@deftypevr {@code{repository-cgit-configuration} parameter} repo-string na= me +The value to show as repository name. + +Defaults to @samp{""}. + +@end deftypevr + +@deftypevr {@code{repository-cgit-configuration} parameter} repo-string ow= ner +A value used to identify the owner of the repository. + +Defaults to @samp{""}. + +@end deftypevr + +@deftypevr {@code{repository-cgit-configuration} parameter} repo-string pa= th +An absolute path to the repository directory. + +Defaults to @samp{""}. + +@end deftypevr + +@deftypevr {@code{repository-cgit-configuration} parameter} repo-string re= adme +A path (relative to repo) which specifies a file to include verbatim as +the "About" page for this repo. + +Defaults to @samp{""}. + +@end deftypevr + +@deftypevr {@code{repository-cgit-configuration} parameter} repo-string se= ction +The name of the current repository section - all repositories defined +after this option will inherit the current section name. + +Defaults to @samp{""}. + +@end deftypevr + +@deftypevr {@code{repository-cgit-configuration} parameter} repo-list extr= a-options +Extra options will be appended to cgitrc file. + +Defaults to @samp{()}. + +@end deftypevr + +@end deftypevr + +@deftypevr {@code{cgit-configuration} parameter} list extra-options +Extra options will be appended to cgitrc file. + +Defaults to @samp{()}. + +@end deftypevr + + +@c %end of fragment + +However, it could be that you just want to get a @code{cgitrc} up and +running. In that case, you can pass an @code{opaque-cgit-configuration} +as a record to @code{cgit-service-type}. As its name indicates, an +opaque configuration does not have easy reflective capabilities. + +Available @code{opaque-cgit-configuration} fields are: + +@deftypevr {@code{opaque-cgit-configuration} parameter} package cgit +The cgit package. +@end deftypevr + +@deftypevr {@code{opaque-cgit-configuration} parameter} string string +The contents of the @code{cgitrc}, as a string. +@end deftypevr + +For example, if your @code{cgitrc} is just the empty string, you +could instantiate a cgit service like this: + +@example +(service cgit-service-type + (opaque-cgit-configuration + (cgitrc ""))) +@end example =20 @node Setuid Programs @subsection Setuid Programs diff --git a/gnu/local.mk b/gnu/local.mk index 6c46c4e5d..00fd94937 100644 =2D-- a/gnu/local.mk +++ b/gnu/local.mk @@ -450,6 +450,7 @@ GNU_SYSTEM_MODULES =3D \ %D%/services/avahi.scm \ %D%/services/base.scm \ %D%/services/certbot.scm \ + %D%/services/cgit.scm \ %D%/services/configuration.scm \ %D%/services/cuirass.scm \ %D%/services/cups.scm \ diff --git a/gnu/services/cgit.scm b/gnu/services/cgit.scm new file mode 100644 index 000000000..e5bf481ef =2D-- /dev/null +++ b/gnu/services/cgit.scm @@ -0,0 +1,683 @@ +;;; GNU Guix --- Functional package management for GNU +;;; Copyright =C2=A9 2018 Oleg Pykhalov +;;; +;;; 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 . + +(define-module (gnu services cgit) + #:use-module (gnu packages admin) + #:use-module (gnu packages version-control) + #:use-module (gnu services base) + #:use-module (gnu services configuration) + #:use-module (gnu services shepherd) + #:use-module (gnu services web) + #:use-module (gnu services) + #:use-module (gnu system shadow) + #:use-module (guix gexp) + #:use-module (guix packages) + #:use-module (guix records) + #:use-module (guix store) + #:use-module (ice-9 match) + #:use-module (srfi srfi-1) + #:use-module (srfi srfi-26) + #:export (repository-cgit-configuration + cgit-configuration + %cgit-configuration-nginx + cgit-configuration-nginx-config + opaque-cgit-configuration + cgit-service-type)) + +;;; Commentary: +;;; +;;; This module provides a service definition for the Cgit a web frontend = for +;;; Git repositories written in C. +;;; +;;; Note: fields of and +;;; should be specified in the specific order. +;;; +;;; Code: + +(define %cgit-configuration-nginx + (nginx-server-configuration + (root cgit) + (locations + (list + (nginx-location-configuration + (uri "@cgit") + (body '("fastcgi_param SCRIPT_FILENAME $document_root/lib/cgit/cgit.= cgi;" + "fastcgi_param PATH_INFO $uri;" + "fastcgi_param QUERY_STRING $args;" + "fastcgi_param HTTP_HOST $server_name;" + "fastcgi_pass 127.0.0.1:9000;"))))) + (try-files (list "$uri" "@cgit")) + (listen '("80")) + (ssl-certificate #f) + (ssl-certificate-key #f))) + + +;;; +;;; Serialize +;;; + +(define (uglify-field-name field-name) + (let ((str (symbol->string field-name))) + (string-join (string-split (string-delete #\? str) #\-) "-"))) + +(define (serialize-field field-name val) + (format #t "~a=3D~a\n" (uglify-field-name field-name) val)) + +(define (serialize-string field-name val) + (if (string=3D? val "") "" (serialize-field field-name val))) + +(define (serialize-boolean field-name val) + (serialize-field field-name (if val 1 0))) + +(define (serialize-list field-name val) + (if (null? val) "" (serialize-field field-name (string-join val)))) + +(define robots-list? list?) + +(define (serialize-robots-list field-name val) + (if (null? val) "" (serialize-field field-name (string-join val ", ")))) + +(define (integer? val) + (exact-integer? val)) + +(define (serialize-integer field-name val) + (serialize-field field-name val)) + +(define (serialize-repository-cgit-configuration x) + (serialize-configuration x repository-cgit-configuration-fields)) + +(define (repository-cgit-configuration-list? val) + (list? val)) + +(define (serialize-repository-cgit-configuration-list field-name val) + (for-each serialize-repository-cgit-configuration val)) + + +;;; +;;; Serialize +;;; + +(define (nginx-server-configuration-list? val) + (and (list? val) (and-map nginx-server-configuration? val))) + +(define (serialize-nginx-server-configuration-list field-name val) + #f) + + +;;; +;;; Serialize +;;; + +(define (serialize-repo-field field-name val) + (format #t "repo.~a=3D~a\n" (uglify-field-name field-name) val)) + +(define (serialize-repo-list field-name val) + (if (null? val) "" (serialize-repo-field field-name (string-join val)))) + +(define repo-boolean? boolean?) + +(define (serialize-repo-boolean field-name val) + (serialize-repo-field field-name (if val 1 0))) + +(define (serialize-repo-integer field-name val) + (serialize-repo-field field-name val)) + +(define repo-list? list?) + +(define repo-string? string?) + +(define (serialize-repo-string field-name val) + (if (string=3D? val "") "" (serialize-repo-field field-name val))) + +(define module-link-path? list?) + +(define (serialize-module-link-path field-name val) + (if (null? val) "" + (match val + ((path text) + (format #t "repo.~a.~a=3D~a\n" + (string-drop-right (uglify-field-name 'module-link-path) + (string-length "-path")) + path text))))) + +(define repository-directory? string?) + +(define (serialize-repository-directory _ val) + (if (string=3D? val "") "" (format #t "scan-path=3D~a\n" val))) + +(define mimetype-alist? list?) + +(define (serialize-mimetype-alist field-name val) + (format #t "# Mimetypes\n~a" + (string-join + (map (match-lambda + ((extension mimetype) + (format #f "mimetype.~a=3D~a" + (symbol->string extension) mimetype))) + val) "\n"))) + +(define-configuration repository-cgit-configuration + (snapshots + (repo-list '()) + "A mask of snapshot formats for this repo that cgit generates links for, +restricted by the global @code{snapshots} setting.") + (source-filter + (repo-string "") + "Override the default @code{source-filter}.") + (url + (repo-string "") + "The relative URL used to access the repository.") + (about-filter + (repo-string "") + "Override the default @code{about-filter}.") + (branch-sort + (repo-string "") + "Flag which, when set to @samp{age}, enables date ordering in the branch +ref list, and when set to @samp{name} enables ordering by branch name.") + (clone-url + (repo-list '()) + "A list of URLs which can be used to clone repo.") + (commit-filter + (repo-string "") + "Override the default @code{commit-filter}.") + (commit-sort + (repo-string "") + "Flag which, when set to @samp{date}, enables strict date ordering in t= he +commit log, and when set to @samp{topo} enables strict topological orderin= g.") + (defbranch + (repo-string "") + "The name of the default branch for this repository. If no such branch +exists in the repository, the first branch name (when sorted) is used as +default instead. By default branch pointed to by HEAD, or \"master\" if t= here +is no suitable HEAD.") + (desc + (repo-string "") + "The value to show as repository description.") + (homepage + (repo-string "") + "The value to show as repository homepage.") + (email-filter + (repo-string "") + "Override the default @code{email-filter}.") + (enable-commit-graph? + (repo-boolean #f) + "A flag which can be used to disable the global setting +@code{enable-commit-graph?}.") + (enable-log-filecount? + (repo-boolean #f) + "A flag which can be used to disable the global setting +@code{enable-log-filecount?}.") + (enable-log-linecount? + (repo-boolean #f) + "A flag which can be used to disable the global setting +@code{enable-log-linecount?}.") + (enable-remote-branches? + (repo-boolean #f) + "Flag which, when set to @code{#t}, will make Cgit display remote +branches in the summary and refs views.") + (enable-subject-links? + (repo-boolean #f) + "A flag which can be used to override the global setting +@code{enable-subject-links?}.") + (enable-html-serving? + (repo-boolean #f) + "A flag which can be used to override the global setting +@code{enable-html-serving?}.") + (hide? + (repo-boolean #f) + "Flag which, when set to @code{#t}, hides the repository from the +repository index.") + (ignore? + (repo-boolean #f) + "Flag which, when set to @samp{#t}, ignores the repository.") + (logo + (repo-string "") + "URL which specifies the source of an image which will be used as a +logo on this repo=E2=80=99s pages.") + (logo-link + (repo-string "") + "URL loaded when clicking on the Cgit logo image.") + (owner-filter + (repo-string "") + "Override the default @code{owner-filter}.") + (module-link + (repo-string "") + "Text which will be used as the formatstring for a hyperlink when a +submodule is printed in a directory listing. The arguments for the +formatstring are the path and SHA1 of the submodule commit.") + (module-link-path + (module-link-path '()) + "Text which will be used as the formatstring for a hyperlink when a +submodule with the specified subdirectory path is printed in a directory +listing.") + (max-stats + (repo-string "") + "Override the default maximum statistics period.") + (name + (repo-string "") + "The value to show as repository name.") + (owner + (repo-string "") + "A value used to identify the owner of the repository.") + (path + (repo-string "") + "An absolute path to the repository directory.") + (readme + (repo-string "") + "A path (relative to repo) which specifies a file to include verbatim +as the \"About\" page for this repo.") + (section + (repo-string "") + "The name of the current repository section - all repositories defined +after this option will inherit the current section name.") + (extra-options + (repo-list '()) + "Extra options will be appended to cgitrc file.")) + +;; Generate a record, which may include a list of +;; , , . +(define-configuration cgit-configuration + (package + (package cgit) + "The CGIT package.") + (nginx + (nginx-server-configuration-list (list %cgit-configuration-nginx)) + "NGINX configuration.") + (about-filter + (string "") + "Specifies a command which will be invoked to format the content of abo= ut +pages (both top-level and for each repository).") + (agefile + (string "") + "Specifies a path, relative to each repository path, which can be used = to +specify the date and time of the youngest commit in the repository.") + (auth-filter + (string "") + "Specifies a command that will be invoked for authenticating repository +access.") + (branch-sort + (string "name") + "Flag which, when set to @samp{age}, enables date ordering in the branch +ref list, and when set @samp{name} enables ordering by branch name.") + (cache-root + (string "/var/cache/cgit") + "Path used to store the Cgit cache entries.") + (cache-static-ttl + (integer -1) + "Number which specifies the time-to-live, in minutes, for the cached +version of repository pages accessed with a fixed SHA1.") + (cache-dynamic-ttl + (integer 5) + "Number which specifies the time-to-live, in minutes, for the cached +version of repository pages accessed without a fixed SHA1.") + (cache-repo-ttl + (integer 5) + "Number which specifies the time-to-live, in minutes, for the cached +version of the repository summary page.") + (cache-root-ttl + (integer 5) + "Number which specifies the time-to-live, in minutes, for the cached +version of the repository index page.") + (cache-scanrc-ttl + (integer 15) + "Number which specifies the time-to-live, in minutes, for the result of +scanning a path for Git repositories.") + (cache-about-ttl + (integer 15) + "Number which specifies the time-to-live, in minutes, for the cached +version of the repository about page.") + (cache-snapshot-ttl + (integer 5) + "Number which specifies the time-to-live, in minutes, for the cached +version of snapshots.") + (cache-size + (integer 0) + "The maximum number of entries in the cgit cache. When set to +@samp{0}, caching is disabled.") + (case-sensitive-sort? + (boolean #t) + "Sort items in the repo list case sensitively.") + (clone-prefix + (list '()) + "List of common prefixes which, when combined with a repository URL, +generates valid clone URLs for the repository.") + (clone-url + (list '()) + "List of @code{clone-url} templates.") + (commit-filter + (string "") + "Command which will be invoked to format commit messages.") + (commit-sort + (string "git log") + "Flag which, when set to @samp{date}, enables strict date ordering in t= he +commit log, and when set to @samp{topo} enables strict topological +ordering.") + (css + (string "/share/cgit/cgit.css") + "URL which specifies the css document to include in all Cgit pages.") + (email-filter + (string "") + "Specifies a command which will be invoked to format names and email +address of committers, authors, and taggers, as represented in various +places throughout the Cgit interface.") + (embedded? + (boolean #f) + "Flag which, when set to @samp{#t}, will make Cgit generate a HTML +fragment suitable for embedding in other HTML pages.") + (enable-commit-graph? + (boolean #f) + "Flag which, when set to @samp{#t}, will make Cgit print an ASCII-art +commit history graph to the left of the commit messages in the +repository log page.") + (enable-filter-overrides? + (boolean #f) + "Flag which, when set to @samp{#t}, allows all filter settings to be +overridden in repository-specific cgitrc files.") + (enable-follow-links? + (boolean #f) + "Flag which, when set to @samp{#t}, allows users to follow a file in the +log view.") + (enable-http-clone? + (boolean #t) + "If set to @samp{#t}, Cgit will act as an dumb HTTP endpoint for Git +clones.") + (enable-index-links? + (boolean #f) + "Flag which, when set to @samp{#t}, will make Cgit generate extra links +\"summary\", \"commit\", \"tree\" for each repo in the repository index.") + (enable-index-owner? + (boolean #t) + "Flag which, when set to @samp{#t}, will make Cgit display the owner of +each repo in the repository index.") + (enable-log-filecount? + (boolean #f) + "Flag which, when set to @samp{#t}, will make Cgit print the number of +modified files for each commit on the repository log page.") + (enable-log-linecount? + (boolean #f) + "Flag which, when set to @samp{#t}, will make Cgit print the number of +added and removed lines for each commit on the repository log page.") + (enable-remote-branches? + (boolean #f) + "Flag which, when set to @code{#t}, will make Cgit display remote +branches in the summary and refs views.") + (enable-subject-links? + (boolean #f) + "Flag which, when set to @code{1}, will make Cgit use the subject of +the parent commit as link text when generating links to parent commits +in commit view.") + (enable-html-serving? + (boolean #f) + "Flag which, when set to @samp{#t}, will make Cgit use the subject of t= he +parent commit as link text when generating links to parent commits in +commit view.") + (enable-tree-linenumbers? + (boolean #t) + "Flag which, when set to @samp{#t}, will make Cgit generate linenumber +links for plaintext blobs printed in the tree view.") + (enable-git-config? + (boolean #f) + "Flag which, when set to @samp{#f}, will allow Cgit to use Git config to +set any repo specific settings.") + (favicon + (string "/favicon.ico") + "URL used as link to a shortcut icon for Cgit.") + (footer + (string "") + "The content of the file specified with this option will be included +verbatim at the bottom of all pages (i.e. it replaces the standard +\"generated by...\" message).") + (head-include + (string "") + "The content of the file specified with this option will be included +verbatim in the HTML HEAD section on all pages.") + (header + (string "") + "The content of the file specified with this option will be included +verbatim at the top of all pages.") + (include + (string "") + "Name of a configfile to include before the rest of the current config- +file is parsed.") + (index-header + (string "") + "The content of the file specified with this option will be included +verbatim above the repository index.") + (index-info + (string "") + "The content of the file specified with this option will be included +verbatim below the heading on the repository index page.") + (local-time? + (boolean #f) + "Flag which, if set to @samp{#t}, makes Cgit print commit and tag times +in the servers timezone.") + (logo + (string "/share/cgit/cgit.png") + "URL which specifies the source of an image which will be used as a logo +on all Cgit pages.") + (logo-link + (string "") + "URL loaded when clicking on the Cgit logo image.") + (owner-filter + (string "") + "Command which will be invoked to format the Owner column of the main +page.") + (max-atom-items + (integer 10) + "Number of items to display in atom feeds view.") + (max-commit-count + (integer 50) + "Number of entries to list per page in \"log\" view.") + (max-message-length + (integer 80) + "Number of commit message characters to display in \"log\" view.") + (max-repo-count + (integer 50) + "Specifies the number of entries to list per page on the repository ind= ex +page.") + (max-repodesc-length + (integer 80) + "Specifies the maximum number of repo description characters to display +on the repository index page.") + (max-blob-size + (integer 0) + "Specifies the maximum size of a blob to display HTML for in KBytes.") + (max-stats + (string "") + "Maximum statistics period. Valid values are @samp{week},@samp{month}, +@samp{quarter} and @samp{year}.") + (mimetype + (mimetype-alist '((gif "image/gif") + (html "text/html") + (jpg "image/jpeg") + (jpeg "image/jpeg") + (pdf "application/pdf") + (png "image/png") + (svg "image/svg+xml"))) + "Mimetype for the specified filename extension.") + (mimetype-file + (string "") + "Specifies the file to use for automatic mimetype lookup.") + (module-link + (string "") + "Text which will be used as the formatstring for a hyperlink when a +submodule is printed in a directory listing.") + (nocache? + (boolean #f) + "If set to the value @samp{#t} caching will be disabled.") + (noplainemail? + (boolean #f) + "If set to @samp{#t} showing full author email addresses will be +disabled.") + (noheader? + (boolean #f) + "Flag which, when set to @samp{#t}, will make Cgit omit the standard +header on all pages.") + (project-list + (string "") + "A list of subdirectories inside of @code{repository-directory}, relati= ve +to it, that should loaded as Git repositories.") + (readme + (string "") + "Text which will be used as default value for @code{cgit-repo-readme}.") + (remove-suffix? + (boolean #f) + "If set to @code{#t} and @code{repository-directory} is enabled, if any +repositories are found with a suffix of @code{.git}, this suffix will be +removed for the URL and name.") + (renamelimit + (integer -1) + "Maximum number of files to consider when detecting renames.") + (repository-sort + (string "") + "The way in which repositories in each section are sorted.") + (robots + (robots-list (list "noindex" "nofollow")) + "Text used as content for the @code{robots} meta-tag.") + (root-desc + (string "a fast webinterface for the git dscm") + "Text printed below the heading on the repository index page.") + (root-readme + (string "") + "The content of the file specified with this option will be included +verbatim below thef \"about\" link on the repository index page.") + (root-title + (string "") + "Text printed as heading on the repository index page.") + (scan-hidden-path + (boolean #f) + "If set to @samp{#t} and repository-directory is enabled, +repository-directory will recurse into directories whose name starts with a +period. Otherwise, repository-directory will stay away from such director= ies, +considered as \"hidden\". Note that this does not apply to the \".git\" +directory in non-bare repos.") + (snapshots + (list '()) + "Text which specifies the default set of snapshot formats that cgit +generates links for.") + (repository-directory + (repository-directory "/srv/git") + "Name of the directory to scan for repositories (represents +@code{scan-path}).") + (section + (string "") + "The name of the current repository section - all repositories defined +after this option will inherit the current section name.") + (section-sort + (string "") + "Flag which, when set to @samp{1}, will sort the sections on the reposi= tory +listing by name.") + (section-from-path + (integer 0) + "A number which, if defined prior to repository-directory, specifies how +many path elements from each repo path to use as a default section name.") + (side-by-side-diffs? + (boolean #f) + "If set to @samp{#t} shows side-by-side diffs instead of unidiffs per +default.") + (source-filter + (string "") + "Specifies a command which will be invoked to format plaintext blobs in= the +tree view.") + (summary-branches + (integer 10) + "Specifies the number of branches to display in the repository \"summar= y\" +view.") + (summary-log + (integer 10) + "Specifies the number of log entries to display in the repository +\"summary\" view.") + (summary-tags + (integer 10) + "Specifies the number of tags to display in the repository \"summary\" +view.") + (strict-export + (string "") + "Filename which, if specified, needs to be present within the repository +for Cgit to allow access to that repository.") + (virtual-root + (string "/") + "URL which, if specified, will be used as root for all Cgit links.") + (repositories + (repository-cgit-configuration-list '()) + "A list of @dfn{cgit-repo} records to use with config.") + (extra-options + (list '()) + "Extra options will be appended to cgitrc file.")) + +(define-configuration opaque-cgit-configuration + (cgit + (package cgit) + "The cgit package.") + (cgitrc + (string (configuration-missing-field 'opaque-cgit-configuration 'cgitrc= )) + "The contents of the @code{cgitrc} to use.") + (cache-root + (string "/var/cache/cgit") + "Path used to store the Cgit cache entries.") + (nginx + (nginx-server-configuration-list (list %cgit-configuration-nginx)) + "NGINX configuration.")) + +(define (cgit-activation config) + "Return the activation gexp for CONFIG." + (let* ((opaque-config? (opaque-cgit-configuration? config)) + (config-str + (if opaque-config? + (opaque-cgit-configuration-cgitrc config) + (with-output-to-string + (lambda () + (serialize-configuration config + cgit-configuration-fields)))))) + #~(begin + (use-modules (guix build utils)) + (mkdir-p #$(if opaque-config? + (opaque-cgit-configuration-cache-root config) + (cgit-configuration-cache-root config))) + (copy-file #$(plain-file "cgitrc" config-str) "/etc/cgitrc")))) + +(define (cgit-configuration-nginx-config config) + (if (opaque-cgit-configuration? config) + (opaque-cgit-configuration-nginx config) + (cgit-configuration-nginx config))) + +(define cgit-service-type + (service-type + (name 'cgit) + (extensions + (list (service-extension activation-service-type + cgit-activation) + (service-extension nginx-service-type + cgit-configuration-nginx-config) + + ;; Make sure fcgiwrap is instantiated. + (service-extension fcgiwrap-service-type + (const #t)))) + (default-value (cgit-configuration)) + (description + "Run the Cgit web interface, which allows users to browse Git +repositories."))) + +(define (generate-cgit-documentation) + (generate-documentation + `((cgit-configuration + ,cgit-configuration-fields + (repositories repository-cgit-configuration)) + (repository-cgit-configuration + ,repository-cgit-configuration-fields)) + 'cgit-configuration)) diff --git a/gnu/services/version-control.scm b/gnu/services/version-contro= l.scm index 7166ed3d4..afead87ec 100644 =2D-- a/gnu/services/version-control.scm +++ b/gnu/services/version-control.scm @@ -38,26 +38,6 @@ git-daemon-configuration git-daemon-configuration? =20 =2D =2D cgit-configuration-file =2D cgit-configuration-file? =2D cgit-configuration-file-css =2D cgit-configuration-file-logo =2D cgit-configuration-file-robots =2D cgit-configuration-file-virtual-root =2D cgit-configuration-file-repository-directory =2D =2D =2D cgit-configuration =2D cgit-configuration? =2D cgit-configuration-config-file =2D cgit-configuration-package =2D =2D %cgit-configuration-nginx =2D cgit-configuration-nginx-config =2D =2D cgit-service-type =2D git-http-configuration git-http-configuration? git-http-nginx-location-configuration)) @@ -173,107 +153,6 @@ access to exported repositories under @file{/srv/git}= ." (service git-daemon-service-type config)) =20 =2D;;; =2D;;; Cgit =2D;;; =2D =2D(define-record-type* =2D cgit-configuration-file =2D make-cgit-configuration-file =2D cgit-configuration-file? =2D (css cgit-configuration-file-css ; s= tring =2D (default "/share/cgit/cgit.css")) =2D (logo cgit-configuration-file-logo ; s= tring =2D (default "/share/cgit/cgit.png")) =2D (robots cgit-configuration-file-robots ; l= ist =2D (default '("noindex" "nofollow"))) =2D (virtual-root cgit-configuration-file-virtual-root ; s= tring =2D (default "/")) =2D (repository-directory cgit-configuration-file-repository-directory ; s= tring =2D (default "/srv/git"))) =2D =2D(define (cgit-configuration-robots-string robots) =2D (string-join robots ", ")) =2D =2D(define-gexp-compiler (cgit-configuration-file-compiler =2D (file ) system target) =2D (match file =2D (($ css logo =2D robots virtual-root repository-directo= ry) =2D (apply text-file* "cgitrc" =2D (letrec-syntax ((option (syntax-rules () =2D ((_ key value) =2D (if value =2D `(,key "=3D" ,value "\n") =2D '())))) =2D (key/value (syntax-rules () =2D ((_ (key value) rest ...) =2D (append (option key value) =2D (key/value rest ...))) =2D ((_) =2D '())))) =2D (key/value ("css" css) =2D ("logo" logo) =2D ("robots" (cgit-configuration-robots-string rob= ots)) =2D ("virtual-root" virtual-root) =2D ("scan-path" repository-directory))))))) =2D =2D(define %cgit-configuration-nginx =2D (list =2D (nginx-server-configuration =2D (root cgit) =2D (locations =2D (list =2D (nginx-location-configuration =2D (uri "@cgit") =2D (body '("fastcgi_param SCRIPT_FILENAME $document_root/lib/cgit/cg= it.cgi;" =2D "fastcgi_param PATH_INFO $uri;" =2D "fastcgi_param QUERY_STRING $args;" =2D "fastcgi_param HTTP_HOST $server_name;" =2D "fastcgi_pass 127.0.0.1:9000;"))))) =2D (try-files (list "$uri" "@cgit")) =2D (listen '("80")) =2D (ssl-certificate #f) =2D (ssl-certificate-key #f)))) =2D =2D(define-record-type* =2D cgit-configuration make-cgit-configuration =2D cgit-configuration? =2D (config-file cgit-configuration-config-file =2D (default (cgit-configuration-file))) =2D (package cgit-configuration-package =2D (default cgit)) =2D (nginx cgit-configuration-nginx =2D (default %cgit-configuration-nginx))) =2D =2D(define (cgit-activation config) =2D ;; Cgit compiled with default configuration path =2D #~(begin =2D (use-modules (guix build utils)) =2D (mkdir-p "/var/cache/cgit") =2D (copy-file #$(cgit-configuration-config-file config) "/etc/cgitrc"= ))) =2D =2D(define (cgit-configuration-nginx-config config) =2D (cgit-configuration-nginx config)) =2D =2D(define cgit-service-type =2D (service-type =2D (name 'cgit) =2D (extensions =2D (list (service-extension activation-service-type =2D cgit-activation) =2D (service-extension nginx-service-type =2D cgit-configuration-nginx-config) =2D =2D ;; Make sure fcgiwrap is instantiated. =2D (service-extension fcgiwrap-service-type =2D (const #t)))) =2D (default-value (cgit-configuration)) =2D (description =2D "Run the Cgit web interface, which allows users to browse Git =2Drepositories."))) =2D =2D ;;; ;;; HTTP access. Add the result of calling ;;; git-http-nginx-location-configuration to an nginx-server-configuration= 's diff --git a/gnu/tests/version-control.scm b/gnu/tests/version-control.scm index 9882cdbe2..802473973 100644 =2D-- a/gnu/tests/version-control.scm +++ b/gnu/tests/version-control.scm @@ -1,5 +1,5 @@ ;;; GNU Guix --- Functional package management for GNU =2D;;; Copyright =C2=A9 2017 Oleg Pykhalov +;;; Copyright =C2=A9 2017, 2018 Oleg Pykhalov ;;; Copyright =C2=A9 2017, 2018 Ludovic Court=C3=A8s ;;; Copyright =C2=A9 2017 Cl=C3=A9ment Lassieur ;;; @@ -26,6 +26,7 @@ #:use-module (gnu system vm) #:use-module (gnu services) #:use-module (gnu services version-control) + #:use-module (gnu services cgit) #:use-module (gnu services web) #:use-module (gnu services networking) #:use-module (gnu packages version-control) =2D-=20 2.15.1 --=-=-= Content-Type: text/plain Oleg. --=-=-=-- --==-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEc+OyAXw1EaDPCmAPckbhHGm3lWkFAlpxN1IACgkQckbhHGm3 lWmgqQ/+PHXS85l/3o5QSHCZRaWewaBpvKH4UT8XNSp8s+j5Jf94NHLM1r8/QbID WgwxfHDkSzNS8CIXAAQwkzMexfTLrKA4h3RpbVKW6F44MvWAvwuj2HLUUQECucSJ cxl6xlJN4G2AbujD/4ek30fp4nswBeKboBzRqjMrbItR2gxXqKes650gPwcuHSq7 woHthMQMdSoLMYuFZEe37mLWRleUgdtbXn560QiOjN+eU3HOFbsp8ux5Dd8HECyL wd1iOQbHIaLfYpdfigZ2yJ4dexu09BSJ2a20nY6Of8Rv0jQJXNW833OQf7jv3ty1 Xoh4gPgxNowDXqe/c/WvJI5hswuI8+JxlUd15SM1LCwgNQKdNe2AxjVKe8keCy4u XRjVK1YiDuUxKLnXHXGYpxwKijUTPzpJVHXgvdd9VRZzWVSwiwYH7SybP2hkd9HE 7dq9EfCfikmaEswo7fqdYGvI287FmfcosZtWat2chGMjFUSpwzc6tafedPAu54+T iPw9Twx8S2PfS7F1iZztf+lHc0D5eYXzv+NJaqoOM9hOcp+DRBBY0ELnxygsECha QFHgfbReBzXHUvviq8NQhbo+oZOEx/lVYRZNtN4upUNjyGkctKsUXANQREg/xzhG yp18XCmr9Ch6J4gRPJ64YEWE5l9j5sGGje1LQrj21K0BIBrPQXk= =4Rno -----END PGP SIGNATURE----- --==-=-=--