2014-04-14 14:26:48 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
2013-05-31 21:53:13 +00:00
|
|
|
|
2014-04-14 14:26:48 +00:00
|
|
|
with lib;
|
2013-05-31 21:53:13 +00:00
|
|
|
|
|
|
|
let
|
|
|
|
cfg = config.services.lighttpd.cgit;
|
|
|
|
configFile = pkgs.writeText "cgitrc"
|
|
|
|
''
|
|
|
|
${cfg.configText}
|
|
|
|
'';
|
|
|
|
in
|
|
|
|
{
|
|
|
|
|
|
|
|
options.services.lighttpd.cgit = {
|
|
|
|
|
|
|
|
enable = mkOption {
|
|
|
|
default = false;
|
2015-06-15 16:10:26 +00:00
|
|
|
type = types.bool;
|
2013-05-31 21:53:13 +00:00
|
|
|
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
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
configText = mkOption {
|
|
|
|
default = "";
|
|
|
|
example = ''
|
|
|
|
cache-size=1000
|
|
|
|
scan-path=/srv/git
|
|
|
|
'';
|
2014-07-23 20:18:37 +00:00
|
|
|
type = types.lines;
|
2013-05-31 21:53:13 +00:00
|
|
|
description = ''
|
|
|
|
Verbatim contents of the cgit runtime configuration file. Documentation
|
|
|
|
(with cgitrc example file) is available in "man cgitrc". Or online:
|
|
|
|
http://git.zx2c4.com/cgit/tree/cgitrc.5.txt
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
|
|
|
|
# make the cgitrc manpage available
|
|
|
|
environment.systemPackages = [ pkgs.cgit ];
|
|
|
|
|
2014-09-07 14:47:49 +00:00
|
|
|
# declare module dependencies
|
|
|
|
services.lighttpd.enableModules = [ "mod_cgi" "mod_alias" "mod_setenv" ];
|
|
|
|
|
2013-05-31 21:53:13 +00:00
|
|
|
services.lighttpd.extraConfig = ''
|
|
|
|
$HTTP["url"] =~ "^/cgit" {
|
|
|
|
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"
|
|
|
|
)
|
|
|
|
setenv.add-environment = (
|
|
|
|
"CGIT_CONFIG" => "${configFile}"
|
|
|
|
)
|
|
|
|
}
|
|
|
|
'';
|
|
|
|
|
2016-07-25 19:22:51 +00:00
|
|
|
systemd.services.lighttpd.preStart = ''
|
|
|
|
mkdir -p /var/cache/cgit
|
|
|
|
chown lighttpd:lighttpd /var/cache/cgit
|
|
|
|
'';
|
|
|
|
|
2013-05-31 21:53:13 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|