summaryrefslogtreecommitdiff
path: root/modules/xnet/gitserver/gitweb.nix
blob: c3696ababb5b16c2c1e74b11d4d0910fd2de8159 (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
{ config, lib, pkgs, ... }:
let
  cfg = config.xnet.gitServer.gitweb;
  inherit (lib) mkOption mkIf types;
in
{
  options.xnet.gitServer.gitweb = {
    enable = mkOption {
      type = types.bool;
      default = false;
      description = "Enable web interface to git repos.";
    };

    hostName = mkOption {
      type = types.str;
      default = "src.web.4kb.net";
      description = "Hostname the webUI is served from.";
    };
  };

  config = mkIf cfg.enable {
    xnet.nginx.enable = true;

    services.cgit.main = {
      enable = true;
      scanPath = config.xnet.gitServer.path;
      package = pkgs.cgit-pink;
      nginx = {
        virtualHost = cfg.hostName;
        location = "/";
      };
      extraConfig = ''
        mimetype.gif=image/gif
        mimetype.html=text/html
        mimetype.jpeg=image/jpeg
        mimetype.jpg=image/jpeg
        mimetype.pdf=application/pdf
        mimetype.png=image/png
        mimetype.svg=image/svg+xml
        readme=:readme
        readme=:readme.md
        readme=:readme.txt
        readme=:README
        readme=:README.md
        readme=:README.txt
      '';
      settings = {
        about-filter = "${pkgs.cgit-pink}/lib/cgit/filters/about-formatting.sh";
        clone-url = "https://${cfg.hostName}/$CGIT_REPO_URL git@${cfg.hostName}:$CGIT_REPO_URL";
        enable-commit-graph = true;
        enable-http-clone = false;
        enable-index-links = true;
        enable-remote-branches = true;
        remove-suffix = true;
        robots = "noindex, nofollow";
        root-desc = "What I cannot create, I do not understand";
        root-title = cfg.hostName;
        section-from-path = true;
        snapshots = "tar.gz tar.bz2 zip";
      };
    };

    # required for rendering markdown readme
    environment.systemPackages = with pkgs; [
      python312
      python312Packages.markdown
    ];

    # services.nginx.virtualHosts."${cfg.gitweb.hostName}" = {
    #   useACMEHost = "4kb.net";
    #   addSSL = true;
    # };
  };
}