Merge pull request #75602 from vanyaklimenko/nginx-gitweb-more-options

nixos/nginx/gitweb: add some (crucial) options
This commit is contained in:
Aaron Andersen 2020-01-15 21:16:24 -05:00 committed by GitHub
commit fc1bee555e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3,8 +3,9 @@
with lib; with lib;
let let
cfg = config.services.gitweb; cfg = config.services.nginx.gitweb;
package = pkgs.gitweb.override (optionalAttrs cfg.gitwebTheme { gitwebConfig = config.services.gitweb;
package = pkgs.gitweb.override (optionalAttrs gitwebConfig.gitwebTheme {
gitwebTheme = true; gitwebTheme = true;
}); });
@ -17,13 +18,45 @@ in
default = false; default = false;
type = types.bool; type = types.bool;
description = '' description = ''
If true, enable gitweb in nginx. Access it at http://yourserver/gitweb 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.
''; '';
}; };
}; };
config = mkIf config.services.nginx.gitweb.enable { config = mkIf cfg.enable {
systemd.services.gitweb = { systemd.services.gitweb = {
description = "GitWeb service"; description = "GitWeb service";
@ -32,22 +65,22 @@ in
FCGI_SOCKET_PATH = "/run/gitweb/gitweb.sock"; FCGI_SOCKET_PATH = "/run/gitweb/gitweb.sock";
}; };
serviceConfig = { serviceConfig = {
User = "nginx"; User = cfg.user;
Group = "nginx"; Group = cfg.group;
RuntimeDirectory = [ "gitweb" ]; RuntimeDirectory = [ "gitweb" ];
}; };
wantedBy = [ "multi-user.target" ]; wantedBy = [ "multi-user.target" ];
}; };
services.nginx = { services.nginx = {
virtualHosts.default = { virtualHosts.${cfg.virtualHost} = {
locations."/gitweb/static/" = { locations."${cfg.location}/static/" = {
alias = "${package}/static/"; alias = "${package}/static/";
}; };
locations."/gitweb/" = { locations."${cfg.location}/" = {
extraConfig = '' extraConfig = ''
include ${pkgs.nginx}/conf/fastcgi_params; include ${pkgs.nginx}/conf/fastcgi_params;
fastcgi_param GITWEB_CONFIG ${cfg.gitwebConfigFile}; fastcgi_param GITWEB_CONFIG ${gitwebConfig.gitwebConfigFile};
fastcgi_pass unix:/run/gitweb/gitweb.sock; fastcgi_pass unix:/run/gitweb/gitweb.sock;
''; '';
}; };