nixpkgs/nixos/modules/services/web-servers/nginx/gitweb.nix

95 lines
2.1 KiB
Nix
Raw Normal View History

2018-03-27 16:42:13 +00:00
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.services.nginx.gitweb;
gitwebConfig = config.services.gitweb;
package = pkgs.gitweb.override (optionalAttrs gitwebConfig.gitwebTheme {
2018-04-17 17:06:44 +00:00
gitwebTheme = true;
});
2018-03-27 16:42:13 +00:00
in
{
options.services.nginx.gitweb = {
enable = mkOption {
default = false;
type = types.bool;
description = ''
If true, enable gitweb in nginx.
'';
};
location = mkOption {
default = "/gitweb";
type = types.str;
description = ''
Location to serve gitweb on.
'';
};
user = mkOption {
default = "nginx";
type = types.str;
description = ''
Existing user that the CGI process will belong to. (Default almost surely will do.)
'';
};
group = mkOption {
default = "nginx";
type = types.str;
description = ''
Group that the CGI process will belong to. (Set to <literal>config.services.gitolite.group</literal> if you are using gitolite.)
'';
};
virtualHost = mkOption {
default = "_";
type = types.str;
description = ''
VirtualHost to serve gitweb on. Default is catch-all.
2018-03-27 16:42:13 +00:00
'';
};
};
config = mkIf cfg.enable {
2018-03-27 16:42:13 +00:00
systemd.services.gitweb = {
description = "GitWeb service";
2018-04-17 17:06:44 +00:00
script = "${package}/gitweb.cgi --fastcgi --nproc=1";
2018-04-06 19:36:03 +00:00
environment = {
FCGI_SOCKET_PATH = "/run/gitweb/gitweb.sock";
};
2018-03-27 16:42:13 +00:00
serviceConfig = {
User = cfg.user;
Group = cfg.group;
2018-04-06 19:36:03 +00:00
RuntimeDirectory = [ "gitweb" ];
2018-03-27 16:42:13 +00:00
};
2018-04-06 19:36:03 +00:00
wantedBy = [ "multi-user.target" ];
2018-03-27 16:42:13 +00:00
};
services.nginx = {
virtualHosts.${cfg.virtualHost} = {
locations."${cfg.location}/static/" = {
2018-04-17 17:06:44 +00:00
alias = "${package}/static/";
2018-04-06 19:36:03 +00:00
};
locations."${cfg.location}/" = {
2018-03-27 16:42:13 +00:00
extraConfig = ''
include ${pkgs.nginx}/conf/fastcgi_params;
fastcgi_param GITWEB_CONFIG ${gitwebConfig.gitwebConfigFile};
2018-04-06 19:36:03 +00:00
fastcgi_pass unix:/run/gitweb/gitweb.sock;
2018-03-27 16:42:13 +00:00
'';
};
};
};
};
meta.maintainers = with maintainers; [ ];
2018-03-27 16:42:13 +00:00
}