3
0
Fork 0
forked from mirrors/nixpkgs
nixpkgs/nixos/modules/services/web-servers/lighttpd/cgit.nix
Bjørn Forsman fca51849ec nixos/lighttpd: add services.lighttpd.enableModules option
This option makes the coupling between lighttpd and its sub-services
more "loose".

While the option is a list, its purpose is to provide a "set" of needed
modules to load for lighttpd to function correctly with its config. The
NixOS lighttpd module ensures that lighttpd modules are loaded no more
than once (because lighttpd dislikes that), and in the correct order.

Also add an assertion that all modules listed in .enableModules are
valid.
2014-10-05 19:15:19 +02:00

69 lines
1.6 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.uniq 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}"
)
}
'';
};
}