about summary refs log tree commit diff
diff options
context:
space:
mode:
authorVincent Ambo <tazjin@google.com>2019-12-18T16·22+0000
committerVincent Ambo <tazjin@google.com>2019-12-18T16·22+0000
commit11022c1b88c4546fb000de2e1ac42066f63009d2 (patch)
tree38d763464afa6f030f800edad1c396a7b673e6ef
parenta40c2474fef27fd0e482f10e95a9ad02dabcb97c (diff)
feat(services/cgit-taz): Check in initial cgit configuration r/180
This is currently just a test to serve examples from my local machine,
nothing more fancy than that.
-rw-r--r--services/cgit-taz/cgit_idx.patch13
-rw-r--r--services/cgit-taz/default.nix51
-rw-r--r--third_party/default.nix2
3 files changed, 66 insertions, 0 deletions
diff --git a/services/cgit-taz/cgit_idx.patch b/services/cgit-taz/cgit_idx.patch
new file mode 100644
index 000000000000..67dbc0c7ab80
--- /dev/null
+++ b/services/cgit-taz/cgit_idx.patch
@@ -0,0 +1,13 @@
+diff --git a/config.h b/config.h
+index 65ab1e3..cde470f 100644
+--- a/config.h
++++ b/config.h
+@@ -327,7 +327,7 @@
+ /* CONFIGURE: A list of index filenames to check.  The files are searched
+ ** for in this order.
+ */
+-#define INDEX_NAMES "index.html", "index.htm", "index.xhtml", "index.xht", "Default.htm", "index.cgi"
++#define INDEX_NAMES "cgit.cgi"
+ 
+ /* CONFIGURE: If this is defined then thttpd will automatically generate
+ ** index pages for directories that don't have an explicit index file.
diff --git a/services/cgit-taz/default.nix b/services/cgit-taz/default.nix
new file mode 100644
index 000000000000..c815d90d3899
--- /dev/null
+++ b/services/cgit-taz/default.nix
@@ -0,0 +1,51 @@
+# 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" ''
+    virtual-root=/cgit.cgi/
+
+    repo.url=depot
+    repo.path=/home/tazjin/depot/.git
+    repo.desc=tazjin's personal monorepo
+  '';
+  cgitPatch = writeText "cgit_config.patch" ''
+    diff --git a/Makefile b/Makefile
+    index 05ea71f..0df886e 100644
+    --- a/Makefile
+    +++ b/Makefile
+    @@ -4,7 +4,7 @@ CGIT_VERSION = v1.2.1
+     CGIT_SCRIPT_NAME = cgit.cgi
+     CGIT_SCRIPT_PATH = /var/www/htdocs/cgit
+     CGIT_DATA_PATH = $(CGIT_SCRIPT_PATH)
+    -CGIT_CONFIG = /etc/cgitrc
+    +CGIT_CONFIG = ${cgitConfig}
+     CACHE_ROOT = /var/cache/cgit
+     prefix = /usr/local
+     libdir = $(prefix)/lib
+  '';
+  cgitWithConfig = cgit.overrideAttrs(old: {
+    patches = old.patches ++ [ cgitPatch ];
+  });
+  thttpdConfig = writeText "thttpd.conf" ''
+    port=8080
+    dir=${cgitWithConfig}/cgit
+    nochroot
+    novhost
+    logfile=/dev/stdout
+    cgipat=**.cgi
+  '';
+  # Patched version of thttpd that serves cgit.cgi as the index
+  thttpdCgit = thttpd.overrideAttrs(old: {
+    patches = [ ./cgit_idx.patch ];
+  });
+in writeShellScriptBin "cgit-launch" ''
+  exec ${thttpdCgit}/bin/thttpd -D -C ${thttpdConfig}
+# ''
diff --git a/third_party/default.nix b/third_party/default.nix
index 272b36a0b4fe..62abcfb7d6e3 100644
--- a/third_party/default.nix
+++ b/third_party/default.nix
@@ -26,6 +26,7 @@ let
       cacert
       cachix
       cargo
+      cgit
       coreutils
       darwin
       dockerTools
@@ -67,6 +68,7 @@ let
       stern
       symlinkJoin
       terraform_0_12
+      thttpd
       tree
       writeShellScriptBin
       writeText