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.
This commit is contained in:
Maximilian Bosch 2026-07-03 19:39:04 +02:00
commit d8f802c855
No known key found for this signature in database
3 changed files with 104 additions and 103 deletions

View file

@ -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

View file

@ -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 = [ ];

View file

@ -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 = [ ];
}