summary refs log tree commit diff
path: root/nixos/modules/services/web-servers
diff options
context:
space:
mode:
authorMatthew Bauer <mjbauer95@gmail.com>2018-06-28 22:13:42 -0400
committerGitHub <noreply@github.com>2018-06-28 22:13:42 -0400
commitbe3a8c4bdb1e99978fa5c2b98836e0feeb43132b (patch)
tree16ee05512a7a7b24eabac0566039e8e85a340ca2 /nixos/modules/services/web-servers
parent3d20d59e8509dec4b3e1533e89a4b4b1bde94dd2 (diff)
parent8b9559e417f529138449a1a80aeed7c3fa449d7f (diff)
downloadnixlib-be3a8c4bdb1e99978fa5c2b98836e0feeb43132b.tar
nixlib-be3a8c4bdb1e99978fa5c2b98836e0feeb43132b.tar.gz
nixlib-be3a8c4bdb1e99978fa5c2b98836e0feeb43132b.tar.bz2
nixlib-be3a8c4bdb1e99978fa5c2b98836e0feeb43132b.tar.lz
nixlib-be3a8c4bdb1e99978fa5c2b98836e0feeb43132b.tar.xz
nixlib-be3a8c4bdb1e99978fa5c2b98836e0feeb43132b.tar.zst
nixlib-be3a8c4bdb1e99978fa5c2b98836e0feeb43132b.zip
Merge pull request #41799 from pacien/patch-4
cgit: Parametrise cgit subdirectory
Diffstat (limited to 'nixos/modules/services/web-servers')
-rw-r--r--nixos/modules/services/web-servers/lighttpd/cgit.nix28
1 files changed, 22 insertions, 6 deletions
diff --git a/nixos/modules/services/web-servers/lighttpd/cgit.nix b/nixos/modules/services/web-servers/lighttpd/cgit.nix
index 710fecc0c05c..e6a054c296dc 100644
--- a/nixos/modules/services/web-servers/lighttpd/cgit.nix
+++ b/nixos/modules/services/web-servers/lighttpd/cgit.nix
@@ -4,8 +4,15 @@ with lib;
 
 let
   cfg = config.services.lighttpd.cgit;
+  pathPrefix = if stringLength cfg.subdir == 0 then "" else "/" + cfg.subdir;
   configFile = pkgs.writeText "cgitrc"
     ''
+      # default paths to static assets
+      css=${pathPrefix}/cgit.css
+      logo=${pathPrefix}/cgit.png
+      favicon=${pathPrefix}/favicon.ico
+
+      # user configuration
       ${cfg.configText}
     '';
 in
@@ -18,8 +25,17 @@ in
       type = types.bool;
       description = ''
         If true, enable cgit (fast web interface for git repositories) as a
-        sub-service in lighttpd. cgit will be accessible at
-        http://yourserver/cgit
+        sub-service in lighttpd.
+      '';
+    };
+
+    subdir = mkOption {
+      default = "cgit";
+      example = "";
+      type = types.str;
+      description = ''
+        The subdirectory in which to serve cgit. The web application will be
+        accessible at http://yourserver/''${subdir}
       '';
     };
 
@@ -48,14 +64,14 @@ in
     services.lighttpd.enableModules = [ "mod_cgi" "mod_alias" "mod_setenv" ];
 
     services.lighttpd.extraConfig = ''
-      $HTTP["url"] =~ "^/cgit" {
+      $HTTP["url"] =~ "^/${cfg.subdir}" {
           cgi.assign = (
               "cgit.cgi" => "${pkgs.cgit}/cgit/cgit.cgi"
           )
           alias.url = (
-              "/cgit.css" => "${pkgs.cgit}/cgit/cgit.css",
-              "/cgit.png" => "${pkgs.cgit}/cgit/cgit.png",
-              "/cgit"     => "${pkgs.cgit}/cgit/cgit.cgi"
+              "${pathPrefix}/cgit.css" => "${pkgs.cgit}/cgit/cgit.css",
+              "${pathPrefix}/cgit.png" => "${pkgs.cgit}/cgit/cgit.png",
+              "${pathPrefix}"          => "${pkgs.cgit}/cgit/cgit.cgi"
           )
           setenv.add-environment = (
               "CGIT_CONFIG" => "${configFile}"