summary refs log tree commit diff
path: root/nixos/modules/services/web-servers
diff options
context:
space:
mode:
authorNotkea <pacien@users.noreply.github.com>2018-06-10 16:25:01 +0200
committerpacien <pacien.trangirard@pacien.net>2018-06-13 00:28:52 +0200
commit8b9559e417f529138449a1a80aeed7c3fa449d7f (patch)
tree3fd766e085701733343cfb61637e833763bf0c7c /nixos/modules/services/web-servers
parentf0bfa9de83082fd27a092f330b22b697a7955883 (diff)
downloadnixlib-8b9559e417f529138449a1a80aeed7c3fa449d7f.tar
nixlib-8b9559e417f529138449a1a80aeed7c3fa449d7f.tar.gz
nixlib-8b9559e417f529138449a1a80aeed7c3fa449d7f.tar.bz2
nixlib-8b9559e417f529138449a1a80aeed7c3fa449d7f.tar.lz
nixlib-8b9559e417f529138449a1a80aeed7c3fa449d7f.tar.xz
nixlib-8b9559e417f529138449a1a80aeed7c3fa449d7f.tar.zst
nixlib-8b9559e417f529138449a1a80aeed7c3fa449d7f.zip
cgit: parametrise subdirectory
This proposal enables the user to choose the sub-directory in which to serve cgit.
The previous default behaviour isn't altered.
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}"