2019-12-18 17:22:56 +01:00
|
|
|
# This derivation configures a 'cgit' instance to serve repositories
|
|
|
|
# from a different source.
|
|
|
|
|
2020-02-21 13:47:29 +01:00
|
|
|
{ depot, ... }:
|
2019-12-18 17:22:56 +01:00
|
|
|
|
2020-02-21 13:47:29 +01:00
|
|
|
with depot.third_party;
|
2019-12-18 17:22:56 +01:00
|
|
|
|
|
|
|
let
|
2020-01-20 00:53:28 +01:00
|
|
|
sourceFilter = writeShellScriptBin "cheddar-about" ''
|
2020-02-21 13:47:29 +01:00
|
|
|
exec ${depot.tools.cheddar}/bin/cheddar --about-filter $@
|
2020-01-20 00:53:28 +01:00
|
|
|
'';
|
2019-12-18 17:22:56 +01:00
|
|
|
cgitConfig = writeText "cgitrc" ''
|
2019-12-18 18:53:57 +01:00
|
|
|
# Global configuration
|
2019-12-20 17:24:15 +01:00
|
|
|
virtual-root=/
|
2019-12-18 18:53:57 +01:00
|
|
|
enable-http-clone=1
|
2019-12-20 19:31:34 +01:00
|
|
|
readme=:README.md
|
2020-01-20 00:53:28 +01:00
|
|
|
about-filter=${sourceFilter}/bin/cheddar-about
|
2020-02-21 13:47:29 +01:00
|
|
|
source-filter=${depot.tools.cheddar}/bin/cheddar
|
2019-12-20 21:47:35 +01:00
|
|
|
enable-log-filecount=1
|
|
|
|
enable-log-linecount=1
|
|
|
|
enable-follow-links=1
|
|
|
|
enable-blame=1
|
2019-12-20 22:17:51 +01:00
|
|
|
mimetype-file=${mime-types}/etc/mime.types
|
2019-12-20 22:18:53 +01:00
|
|
|
logo=/plain/fun/logo/depot-logo.png
|
2019-12-18 17:22:56 +01:00
|
|
|
|
2019-12-18 18:53:57 +01:00
|
|
|
# Repository configuration
|
2019-12-18 17:22:56 +01:00
|
|
|
repo.url=depot
|
2020-06-11 23:48:58 +02:00
|
|
|
repo.path=/var/lib/gerrit/git/depot.git/
|
2021-03-31 21:16:56 +02:00
|
|
|
repo.desc=monorepo for the virus lounge
|
2019-12-20 19:31:34 +01:00
|
|
|
repo.owner=tazjin <mail@tazj.in>
|
2020-06-12 03:01:08 +02:00
|
|
|
repo.clone-url=https://code.tvl.fyi
|
2019-12-18 17:22:56 +01:00
|
|
|
'';
|
2019-12-20 18:28:35 +01:00
|
|
|
|
2019-12-18 17:22:56 +01:00
|
|
|
thttpdConfig = writeText "thttpd.conf" ''
|
2020-02-12 02:03:31 +01:00
|
|
|
port=2448
|
2020-01-12 03:53:01 +01:00
|
|
|
dir=${cgit}/cgit
|
2019-12-18 17:22:56 +01:00
|
|
|
nochroot
|
|
|
|
novhost
|
|
|
|
cgipat=**.cgi
|
|
|
|
'';
|
2019-12-18 18:53:57 +01:00
|
|
|
|
|
|
|
# Patched version of thttpd that serves cgit.cgi as the index and
|
|
|
|
# sets the environment variable for pointing cgit at the correct
|
|
|
|
# configuration.
|
|
|
|
#
|
|
|
|
# Things are done this way because recompilation of thttpd is much
|
|
|
|
# faster than cgit and I don't want to wait long when iterating on
|
|
|
|
# config.
|
|
|
|
thttpdConfigPatch = writeText "thttpd_cgit_conf.patch" ''
|
|
|
|
diff --git a/libhttpd.c b/libhttpd.c
|
|
|
|
index c6b1622..eef4b73 100644
|
|
|
|
--- a/libhttpd.c
|
|
|
|
+++ b/libhttpd.c
|
|
|
|
@@ -3055,4 +3055,6 @@ make_envp( httpd_conn* hc )
|
|
|
|
|
|
|
|
envn = 0;
|
|
|
|
+ // force cgit to load the correct configuration
|
|
|
|
+ envp[envn++] = "CGIT_CONFIG=${cgitConfig}";
|
|
|
|
envp[envn++] = build_env( "PATH=%s", CGI_PATH );
|
|
|
|
#ifdef CGI_LD_LIBRARY_PATH
|
|
|
|
'';
|
2019-12-18 17:22:56 +01:00
|
|
|
thttpdCgit = thttpd.overrideAttrs(old: {
|
2019-12-22 00:36:02 +01:00
|
|
|
patches = [
|
|
|
|
./thttpd_cgi_idx.patch
|
|
|
|
thttpdConfigPatch
|
|
|
|
];
|
2019-12-18 17:22:56 +01:00
|
|
|
});
|
|
|
|
in writeShellScriptBin "cgit-launch" ''
|
|
|
|
exec ${thttpdCgit}/bin/thttpd -D -C ${thttpdConfig}
|
2020-01-12 03:53:01 +01:00
|
|
|
''
|