1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2024-12-19 12:28:51 +00:00
nixpkgs/nixos/modules/services/web-servers/lighttpd/cgit.nix
Bjørn Forsman 0a2174f195 nixos/lighttpd: move cgit setup to cgit.nix
To where it really belongs. Separation of concern.
2016-07-26 15:37:24 +02:00

74 lines
1.7 KiB
Nix

{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.services.lighttpd.cgit;
configFile = pkgs.writeText "cgitrc"
''
${cfg.configText}
'';
in
{
options.services.lighttpd.cgit = {
enable = mkOption {
default = false;
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
'';
};
configText = mkOption {
default = "";
example = ''
cache-size=1000
scan-path=/srv/git
'';
type = types.lines;
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 ];
# declare module dependencies
services.lighttpd.enableModules = [ "mod_cgi" "mod_alias" "mod_setenv" ];
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}"
)
}
'';
systemd.services.lighttpd.preStart = ''
mkdir -p /var/cache/cgit
chown lighttpd:lighttpd /var/cache/cgit
'';
};
}