@@ -0,0 +1,64 @@
1+{ config, lib, pkgs, ... }:
2+
3+with lib;
4+
5+let
6+ cfg = config.services.gitweb;
7+
8+in
9+{
10+
11+ options.services.nginx.gitweb = {
12+
13+ enable = mkOption {
14+ default = false;
15+ type = types.bool;
16+ description = ''
17+ If true, enable gitweb in nginx. Access it at http://yourserver/gitweb
18+ '';
19+ };
20+
21+ };
22+
23+ config = mkIf config.services.nginx.gitweb.enable {
24+
25+ systemd.sockets.gitweb = {
26+ description = "GitWeb Listen Socket";
27+ listenStreams = [ "/run/gitweb.sock" ];
28+ socketConfig = {
29+ Accept = "false";
30+ SocketUser = "nginx";
31+ SocketGroup = "nginx";
32+ SocketMode = "0600";
33+ };
34+ wantedBy = [ "sockets.target" ];
35+ };
36+ systemd.services.gitweb = {
37+ description = "GitWeb service";
38+ script = "${git}/share/gitweb/gitweb.cgi --fcgi";
39+ serviceConfig = {
40+ Type = "simple";
41+ StandardInput = "socket";
42+ User = "nginx";
43+ Group = "nginx";
44+ };
45+ };
46+
47+ services.nginx = {
48+ virtualHosts.default = {
49+ locations."/gitweb" = {
50+ root = "${pkgs.git}/share/gitweb";
51+ extraConfig = ''
52+ include ${pkgs.nginx}/conf/fastcgi_params;
53+ fastcgi_param GITWEB_CONFIG ${cfg.gitwebConfigFile};
54+ fastcgi_pass unix:/run/gitweb.sock;
55+ '';
56+ };
57+ };
58+ };
59+
60+ };
61+
62+ meta.maintainers = with maintainers; [ gnidorah ];
63+
64+}