summaryrefslogtreecommitdiff
path: root/modules/services/cgit.nix
blob: 20bc939f8f61b81e218d44a13afc7eb6d59b2335 (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
{
  config,
  lib,
  ...
}:
let
  host = "git.rulkc.org";
  mkAssetPath = file: toString (./. + "/../../git.rulkc.org/cgit/${file}");
in
{
  options.landau.services.cgit.enable = lib.mkEnableOption "cgit configured for LANDAU";

  config = lib.mkIf config.landau.services.cgit.enable {
    services.nginx.virtualHosts.${host}.locations = {
      "= /cgit.png".alias = mkAssetPath "cgit.png";
      "= /cgit.css".alias = mkAssetPath "cgit.css";
      "= /favicon.ico".alias = mkAssetPath "favicon.ico";
    };

    services.cgit.${host} = {
      enable = true;
      user = "git";
      group = "git";
      scanPath = "/var/lib/git";
      gitHttpBackend.checkExportOkFiles = false;
      settings = {
        # Features
        enable-git-config = true;
        enable-http-clone = true;
        enable-index-owner = true;
        snapshots = "tar.gz zip";

        # Appearance
        root-title = "LANDAU git repositories";
        root-desc = "Git repositories for Linux kernel Advanced for Next-gen Devices & Architectures";

        clone-url =
          "https://${host}/$CGIT_REPO_URL git://${host}/$CGIT_REPO_URL"
          + (if config.landau.services.gitolite.enable then " ssh://git@${host}/$CGIT_REPO_URL" else "");
        section-from-path = 3;
        max-stats = "quarter";
        cache-root = "/var/cache/cgit";
        cache-size = 1000;
      };
    };

    services.gitDaemon = {
      enable = true;
      basePath = "/var/lib/git";
      exportAll = true;
    };

    networking.firewall.allowedTCPPorts = [
      80
      9418
    ];
  };
}