1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2024-09-11 15:08:33 +01:00
nixpkgs/nixos/modules/services/web-servers/lighttpd/gitweb.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

71 lines
1.6 KiB
Nix

{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.services.lighttpd.gitweb;
gitwebConfigFile = pkgs.writeText "gitweb.conf" ''
# path to git projects (<project>.git)
$projectroot = "${cfg.projectroot}";
${cfg.extraConfig}
'';
in
{
options.services.lighttpd.gitweb = {
enable = mkOption {
default = false;
type = types.uniq types.bool;
description = ''
If true, enable gitweb in lighttpd. Access it at http://yourserver/gitweb
'';
};
projectroot = mkOption {
default = "/srv/git";
type = types.path;
description = ''
Path to git projects (bare repositories) that should be served by
gitweb. Must not end with a slash.
'';
};
extraConfig = mkOption {
default = "";
type = types.lines;
description = ''
Verbatim configuration text appended to the generated gitweb.conf file.
'';
};
};
config = mkIf cfg.enable {
# declare module dependencies
services.lighttpd.enableModules = [ "mod_cgi" "mod_redirect" "mod_alias" "mod_setenv" ];
services.lighttpd.extraConfig = ''
$HTTP["url"] =~ "^/gitweb" {
cgi.assign = (
".cgi" => "${pkgs.perl}/bin/perl"
)
url.redirect = (
"^/gitweb$" => "/gitweb/"
)
alias.url = (
"/gitweb/static/" => "${pkgs.git}/share/gitweb/static/",
"/gitweb/" => "${pkgs.git}/share/gitweb/gitweb.cgi"
)
setenv.add-environment = (
"GITWEB_CONFIG" => "${gitwebConfigFile}"
)
}
'';
};
}