From d8f802c855afc68761e81270a64088c37ed094fb Mon Sep 17 00:00:00 2001 From: Maximilian Bosch Date: Fri, 3 Jul 2026 19:39:04 +0200 Subject: [PATCH] nixos/nginx/gitweb: move into gitweb module I don't see how this was ever considered a good idea, but that's part of a service-module and is not the responsibility of the nginx maintainers. --- nixos/modules/module-list.nix | 1 - nixos/modules/services/misc/gitweb.nix | 105 +++++++++++++++++- .../services/web-servers/nginx/gitweb.nix | 101 ----------------- 3 files changed, 104 insertions(+), 103 deletions(-) delete mode 100644 nixos/modules/services/web-servers/nginx/gitweb.nix diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index 692b4462c928..6f4cbe9fcc07 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -1848,7 +1848,6 @@ ./services/web-servers/minio.nix ./services/web-servers/molly-brown.nix ./services/web-servers/nginx/default.nix - ./services/web-servers/nginx/gitweb.nix ./services/web-servers/nginx/tailscale-auth.nix ./services/web-servers/phpfpm/default.nix ./services/web-servers/pomerium.nix diff --git a/nixos/modules/services/misc/gitweb.nix b/nixos/modules/services/misc/gitweb.nix index 3030dc5c8285..65f923add2d5 100644 --- a/nixos/modules/services/misc/gitweb.nix +++ b/nixos/modules/services/misc/gitweb.nix @@ -6,7 +6,12 @@ }: let cfg = config.services.gitweb; - + cfgNginx = config.services.gitweb.nginx; + package = pkgs.gitweb.override ( + lib.optionalAttrs cfg.gitwebTheme { + gitwebTheme = true; + } + ); in { @@ -55,6 +60,104 @@ in internal = true; }; + nginx = { + enable = lib.mkOption { + default = false; + type = lib.types.bool; + description = '' + If true, enable gitweb in nginx. + ''; + }; + + location = lib.mkOption { + default = "/gitweb"; + type = lib.types.str; + description = '' + Location to serve gitweb on. + ''; + }; + + user = lib.mkOption { + default = "nginx"; + type = lib.types.str; + description = '' + Existing user that the CGI process will belong to. (Default almost surely will do.) + ''; + }; + + group = lib.mkOption { + default = "nginx"; + type = lib.types.str; + description = '' + Group that the CGI process will belong to. (Set to `config.services.gitolite.group` if you are using gitolite.) + ''; + }; + + virtualHost = lib.mkOption { + default = "_"; + type = lib.types.str; + description = '' + VirtualHost to serve gitweb on. Default is catch-all. + ''; + }; + }; + + }; + + imports = [ + (lib.mkRenamedOptionModule + [ "services" "nginx" "gitweb" "enable" ] + [ "services" "gitweb" "nginx" "enable" ] + ) + (lib.mkRenamedOptionModule + [ "services" "nginx" "gitweb" "location" ] + [ "services" "gitweb" "nginx" "location" ] + ) + (lib.mkRenamedOptionModule + [ "services" "nginx" "gitweb" "user" ] + [ "services" "gitweb" "nginx" "user" ] + ) + (lib.mkRenamedOptionModule + [ "services" "nginx" "gitweb" "group" ] + [ "services" "gitweb" "nginx" "group" ] + ) + (lib.mkRenamedOptionModule + [ "services" "nginx" "gitweb" "virtualHost" ] + [ "services" "gitweb" "nginx" "virtualHost" ] + ) + ]; + + config = lib.mkIf cfgNginx.enable { + + systemd.services.gitweb = { + description = "GitWeb service"; + script = "${package}/gitweb.cgi --fastcgi --nproc=1"; + environment = { + FCGI_SOCKET_PATH = "/run/gitweb/gitweb.sock"; + }; + serviceConfig = { + User = cfgNginx.user; + Group = cfgNginx.group; + RuntimeDirectory = [ "gitweb" ]; + }; + wantedBy = [ "multi-user.target" ]; + }; + + services.nginx = { + virtualHosts.${cfgNginx.virtualHost} = { + locations."${cfgNginx.location}/static/" = { + alias = "${package}/static/"; + }; + locations."${cfgNginx.location}/" = { + extraConfig = '' + include ${config.services.nginx.package}/conf/fastcgi_params; + fastcgi_param GITWEB_CONFIG ${cfg.gitwebConfigFile}; + fastcgi_pass unix:/run/gitweb/gitweb.sock; + ''; + }; + }; + }; + }; meta.maintainers = [ ]; diff --git a/nixos/modules/services/web-servers/nginx/gitweb.nix b/nixos/modules/services/web-servers/nginx/gitweb.nix deleted file mode 100644 index c379245c5bff..000000000000 --- a/nixos/modules/services/web-servers/nginx/gitweb.nix +++ /dev/null @@ -1,101 +0,0 @@ -{ - config, - lib, - pkgs, - ... -}: - -with lib; - -let - cfg = config.services.nginx.gitweb; - gitwebConfig = config.services.gitweb; - package = pkgs.gitweb.override ( - optionalAttrs gitwebConfig.gitwebTheme { - gitwebTheme = true; - } - ); - -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 `config.services.gitolite.group` if you are using gitolite.) - ''; - }; - - virtualHost = mkOption { - default = "_"; - type = types.str; - description = '' - VirtualHost to serve gitweb on. Default is catch-all. - ''; - }; - - }; - - config = mkIf cfg.enable { - - systemd.services.gitweb = { - description = "GitWeb service"; - script = "${package}/gitweb.cgi --fastcgi --nproc=1"; - environment = { - FCGI_SOCKET_PATH = "/run/gitweb/gitweb.sock"; - }; - serviceConfig = { - User = cfg.user; - Group = cfg.group; - RuntimeDirectory = [ "gitweb" ]; - }; - wantedBy = [ "multi-user.target" ]; - }; - - services.nginx = { - virtualHosts.${cfg.virtualHost} = { - locations."${cfg.location}/static/" = { - alias = "${package}/static/"; - }; - locations."${cfg.location}/" = { - extraConfig = '' - include ${config.services.nginx.package}/conf/fastcgi_params; - fastcgi_param GITWEB_CONFIG ${gitwebConfig.gitwebConfigFile}; - fastcgi_pass unix:/run/gitweb/gitweb.sock; - ''; - }; - }; - }; - - }; - - meta.maintainers = [ ]; - -}