summaryrefslogtreecommitdiff
path: root/sys/web/sites/cgit.nix
blob: 09b3792aefc37026aca49b7f5d7705be6734e740 (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
{
  config,
  lib,
  options,
  pkgs,
  ...
}:
with lib; let
  cfg = config.local.web.sites.cgit;
  inherit (config.local) domains;
in {
  options.local.web.sites.cgit = {
    enable = mkEnableOption "cgit site";

    repos = mkOption {
      default = {};
      type = (options.services.cgit.type.nestedTypes.elemType.getSubOptions {}).repos.type;
    };
  };

  config = mkIf cfg.enable {
    local.web = {
      enable = mkDefault true;
      ownedCerts = ["cgit"];
    };

    services = {
      cgit.${domains.cgit.main} = {
        enable = true;

        inherit (cfg) repos;

        settings = {
          enable-follow-links = true;
          source-filter = "${pkgs.cgit}/lib/cgit/filters/syntax-highlighting.py";
        };
      };

      nginx.virtualHosts.${domains.cgit.main} = {
        forceSSL = true;
        useACMEHost = domains.cgit.main;
      };
    };
  };
}