Merge pull request #41799 from pacien/patch-4

cgit: Parametrise cgit subdirectory
This commit is contained in:
Matthew Bauer 2018-06-28 22:13:42 -04:00 committed by GitHub
commit be3a8c4bdb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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}"