summary refs log tree commit diff
path: root/nixos/modules/services/web-servers/nginx/gitweb.nix
blob: 344c1f7b8aa488035b72146d9ccb091e3b3463ba (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
{ config, lib, pkgs, ... }:

with lib;

let
  cfg = config.services.gitweb;

in
{

  options.services.nginx.gitweb = {

    enable = mkOption {
      default = false;
      type = types.bool;
      description = ''
        If true, enable gitweb in nginx. Access it at http://yourserver/gitweb
      '';
    };

  };

  config = mkIf config.services.nginx.gitweb.enable {

    systemd.sockets.gitweb = {
      description = "GitWeb Listen Socket";
      listenStreams = [ "/run/gitweb.sock" ];
      socketConfig = {
        Accept = "false";
        SocketUser = "nginx";
        SocketGroup = "nginx";
        SocketMode = "0600";
      };
      wantedBy = [ "sockets.target" ];
    };
    systemd.services.gitweb = {
      description = "GitWeb service";
      script = "${git}/share/gitweb/gitweb.cgi --fcgi";
      serviceConfig = {
        Type = "simple";
        StandardInput = "socket";
        User = "nginx";
        Group = "nginx";
      };
    };

    services.nginx = {
      virtualHosts.default = {
        locations."/gitweb" = {
          root = "${pkgs.git}/share/gitweb";
          extraConfig = ''
            include ${pkgs.nginx}/conf/fastcgi_params;
            fastcgi_param GITWEB_CONFIG ${cfg.gitwebConfigFile};
            fastcgi_pass unix:/run/gitweb.sock;
          '';
        };
      };
    };

  };

  meta.maintainers = with maintainers; [ gnidorah ];

}