about summary refs log tree commit diff
path: root/colmena/cobalt/services/cgit.nix
blob: c6679152048b0e9045b664aedfa963ce53f2fca2 (plain)
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
{ pkgs, ... }:

{
  services.uwsgi = {
    enable = true;
    user = "nginx";
    group = "nginx";
    plugins = [ "cgi" ];

    instance = {
      type = "emperor";
      vassals = {
        cgit = {
          type = "normal";
          master = true;
          socket = "/run/uwsgi/cgit.sock";
          procname-master = "uwsgi cgit";
          plugins = [ "cgi" ];
          cgi = "${pkgs.cgit-pink}/cgit/cgit.cgi";
        };
      };
    };
  };

  users.extraUsers.nginx.extraGroups = [ "git" ];

  services.nginx.virtualHosts."git.sefidel.com" = {
    addSSL = true;
    useACMEHost = "sefidel.com";
    root = "${pkgs.cgit-pink}/cgit";
    locations = {
      "/" = {
        extraConfig = ''
          try_files $uri @cgit;
        '';
      };
      "@cgit" = {
        extraConfig = ''
          uwsgi_pass unix:/run/uwsgi/cgit.sock;
          include ${pkgs.nginx}/conf/uwsgi_params;
          uwsgi_modifier1 9;
        '';
      };
    };
  };

  networking.firewall.allowedTCPPorts = [ 80 443 ];

  systemd.services.create-cgit-cache = {
    description = "Create cache directory for cgit";
    enable = true;

    script = ''
      mkdir -p /run/cgit
      chown -R nginx:nginx /run/cgit
    '';

    wantedBy = [ "uwsgi.service" ];
    serviceConfig = {
      Type = "oneshot";
    };
  };

  environment.etc."cgitrc".text = ''
    virtual-root=/

    cache-size=1000
    cache-root=/run/cgit

    root-title=sefidel git
    root-desc=Exotic place.

    snapshots=tar.gz zip

    enable-git-config=1
    enable-gitweb-owner=1
    remove-suffix=1

    readme=:README
    readme=:readme
    readme=:README.md
    readme=:readme.md
    readme=:README.org
    readme=:readme.org

    source-filter=${pkgs.cgit-pink}/lib/cgit/filters/syntax-highlighting.py
    about-filter=${pkgs.cgit-pink}/lib/cgit/filters/about-formatting.sh

    project-list=/var/lib/gitolite/projects.list
    scan-path=/var/lib/gitolite/repositories
  '';

  imports = [
    ./nginx.nix
  ];
}