diff options
author | Vanya Klimenko <k60+git@fmap.me> | 2020-01-14 00:11:10 +0000 |
---|---|---|
committer | Vanya Klimenko <k60+git@fmap.me> | 2020-01-14 00:11:10 +0000 |
commit | ed52a6567c030c77b6f46a60c0bc8970239400f9 (patch) | |
tree | 954029ce1b37e2728dabbcd9578f6a8c96697a72 /nixos/modules/services/web-servers | |
parent | 3140fa89c51233397f496f49014f6b23216667c2 (diff) | |
download | nixlib-ed52a6567c030c77b6f46a60c0bc8970239400f9.tar nixlib-ed52a6567c030c77b6f46a60c0bc8970239400f9.tar.gz nixlib-ed52a6567c030c77b6f46a60c0bc8970239400f9.tar.bz2 nixlib-ed52a6567c030c77b6f46a60c0bc8970239400f9.tar.lz nixlib-ed52a6567c030c77b6f46a60c0bc8970239400f9.tar.xz nixlib-ed52a6567c030c77b6f46a60c0bc8970239400f9.tar.zst nixlib-ed52a6567c030c77b6f46a60c0bc8970239400f9.zip |
nixos/nginx/gitweb: add some (crucial) options
This replaces some hardcoded values in nginx's VirtualHosts's configuration with customizable options. Previous values are kept as default, so nothing should break for existing users. Co-Authored-By: Florian Klink <flokli@flokli.de>
Diffstat (limited to 'nixos/modules/services/web-servers')
-rw-r--r-- | nixos/modules/services/web-servers/nginx/gitweb.nix | 53 |
1 files changed, 43 insertions, 10 deletions
diff --git a/nixos/modules/services/web-servers/nginx/gitweb.nix b/nixos/modules/services/web-servers/nginx/gitweb.nix index 272fd1480185..f7fb07bb7975 100644 --- a/nixos/modules/services/web-servers/nginx/gitweb.nix +++ b/nixos/modules/services/web-servers/nginx/gitweb.nix @@ -3,8 +3,9 @@ with lib; let - cfg = config.services.gitweb; - package = pkgs.gitweb.override (optionalAttrs cfg.gitwebTheme { + cfg = config.services.nginx.gitweb; + gitwebConfig = config.services.gitweb; + package = pkgs.gitweb.override (optionalAttrs gitwebConfig.gitwebTheme { gitwebTheme = true; }); @@ -17,13 +18,45 @@ in default = false; type = types.bool; 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 = { description = "GitWeb service"; @@ -32,22 +65,22 @@ in FCGI_SOCKET_PATH = "/run/gitweb/gitweb.sock"; }; serviceConfig = { - User = "nginx"; - Group = "nginx"; + User = cfg.user; + Group = cfg.group; RuntimeDirectory = [ "gitweb" ]; }; wantedBy = [ "multi-user.target" ]; }; services.nginx = { - virtualHosts.default = { - locations."/gitweb/static/" = { + virtualHosts.${cfg.virtualHost} = { + locations."${cfg.location}/static/" = { alias = "${package}/static/"; }; - locations."/gitweb/" = { + locations."${cfg.location}/" = { extraConfig = '' 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; ''; }; |