2019-12-18 17:22:56 +01:00
|
|
|
# This derivation configures a 'cgit' instance to serve repositories
|
|
|
|
# from a different source.
|
2021-04-10 18:05:16 +02:00
|
|
|
{ depot, pkgs, ... }:
|
2019-12-18 17:22:56 +01:00
|
|
|
|
|
|
|
let
|
2021-04-10 18:05:16 +02:00
|
|
|
inherit (pkgs)
|
|
|
|
mime-types
|
|
|
|
thttpd
|
|
|
|
writeShellScriptBin
|
|
|
|
writeText
|
|
|
|
;
|
|
|
|
|
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=/
|
2021-09-16 18:20:18 +02:00
|
|
|
enable-http-clone=0
|
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
|
2021-10-01 18:57:43 +02:00
|
|
|
logo=https://static.tvl.fyi/${depot.web.static.drvHash}/logo-animated.svg
|
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
|
2021-09-16 18:20:18 +02:00
|
|
|
repo.owner=The Virus Lounge
|
2021-09-16 17:46:17 +02:00
|
|
|
repo.clone-url=https://code.tvl.fyi/depot.git
|
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
|
2021-04-10 18:05:16 +02:00
|
|
|
dir=${depot.third_party.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
|
|
|
|
'';
|
2022-01-30 17:06:58 +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
|
|
|
});
|
2022-01-30 17:06:58 +01:00
|
|
|
in
|
|
|
|
writeShellScriptBin "cgit-launch" ''
|
2019-12-18 17:22:56 +01:00
|
|
|
exec ${thttpdCgit}/bin/thttpd -D -C ${thttpdConfig}
|
2020-01-12 03:53:01 +01:00
|
|
|
''
|