about summary refs log tree commit diff
path: root/ops/modules/cgit.nix
blob: fc3f17158579fa11f2a74f6fe336e668f405fe0d (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
# Configuration for running the TVL cgit instance using thttpd.
{ config, depot, lib, pkgs, ... }:

let
  cfg = config.services.depot.cgit;

  userConfig =
    if builtins.isNull cfg.user then {
      DynamicUser = true;
    } else {
      User = cfg.user;
      Group = cfg.user;
    };
in
{
  options.services.depot.cgit = with lib; {
    enable = mkEnableOption "Run cgit web interface for depot";

    port = mkOption {
      description = "Port on which cgit should listen";
      type = types.int;
      default = 2448;
    };

    repo = mkOption {
      description = "Path to depot's .git folder on the machine";
      type = types.str;
      default = "/var/lib/gerrit/git/depot.git/";
    };

    user = mkOption {
      description = ''
        User to use for the cgit service. It is expected that this is
        also the name of the user's primary group.
      '';

      type = with types; nullOr str;
      default = null;
    };
  };

  config = lib.mkIf cfg.enable {
    systemd.services.cgit = {
      wantedBy = [ "multi-user.target" ];

      serviceConfig = {
        Restart = "on-failure";

        ExecStart = depot.web.cgit-tvl.override {
          inherit (cfg) port repo;
        };
      } // userConfig;
    };
  };
}