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
|
|
|
|
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 17:11:22 +01:00
|
|
|
readme = README.md
|
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-20 15:23:14 +01:00
|
|
|
repo.path=/git/depot/.git
|
2019-12-18 17:22:56 +01:00
|
|
|
repo.desc=tazjin's personal monorepo
|
2019-12-18 18:53:57 +01:00
|
|
|
repo.owner=tazjin <tazjin@google.com>
|
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
|
|
|
|
|
|
|
# Patched version of cgit that builds repository URLs correctly
|
|
|
|
# (since only one repository is served)
|
|
|
|
monocgit = cgit.overrideAttrs(old: {
|
|
|
|
patches = old.patches ++ [ ./cgit_depot_url.patch ];
|
|
|
|
});
|
|
|
|
|
2019-12-18 17:22:56 +01:00
|
|
|
thttpdConfig = writeText "thttpd.conf" ''
|
|
|
|
port=8080
|
2019-12-20 18:28:35 +01:00
|
|
|
dir=${monocgit}/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-18 18:53:57 +01:00
|
|
|
patches = [ ./cgit_idx.patch thttpdConfigPatch ];
|
2019-12-18 17:22:56 +01:00
|
|
|
});
|
|
|
|
in writeShellScriptBin "cgit-launch" ''
|
|
|
|
exec ${thttpdCgit}/bin/thttpd -D -C ${thttpdConfig}
|
|
|
|
# ''
|