2019-12-18 17:22:56 +01:00
|
|
|
# This derivation configures a 'cgit' instance to serve repositories
|
|
|
|
# from a different source.
|
|
|
|
#
|
|
|
|
# In the first round this will just serve my GitHub repositories until
|
|
|
|
# I'm happy with the display.
|
|
|
|
|
|
|
|
{ pkgs, ... }:
|
|
|
|
|
|
|
|
with pkgs.third_party;
|
|
|
|
|
|
|
|
let
|
2020-01-20 00:53:28 +01:00
|
|
|
sourceFilter = writeShellScriptBin "cheddar-about" ''
|
|
|
|
exec ${pkgs.tools.cheddar}/bin/cheddar --about-filter $@
|
|
|
|
'';
|
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
|
2019-12-21 05:57:55 +01:00
|
|
|
source-filter=${pkgs.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
|
2019-12-30 05:13:54 +01:00
|
|
|
repo.path=/git/depot/
|
2019-12-18 17:22:56 +01:00
|
|
|
repo.desc=tazjin's personal monorepo
|
2019-12-20 19:31:34 +01:00
|
|
|
repo.owner=tazjin <mail@tazj.in>
|
2019-12-18 20:37:41 +01:00
|
|
|
repo.clone-url=https://git.tazj.in ssh://source.developers.google.com:2022/p/tazjins-infrastructure/r/depot
|
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" ''
|
|
|
|
port=8080
|
2020-01-12 03:53:01 +01:00
|
|
|
dir=${cgit}/cgit
|
2019-12-18 17:22:56 +01:00
|
|
|
nochroot
|
|
|
|
novhost
|
|
|
|
logfile=/dev/stdout
|
|
|
|
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
|
|
|
''
|