summaryrefslogtreecommitdiff
path: root/nixos/services/forgejo/default.nix
blob: b15d2d92443bd749d2a153003effd608464fe2bc (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
{
  config,
  lib,
  pkgs,
  ...
}:
with lib; let
  cfg = config.options.trivium.services.forgejo;
in {
  options.trivium.services.forgejo = {
    enable = mkEnableOption "forgejo settings";

    virtualHost = mkOption {
      type = types.string;
      description = "Virtualhost to use for nginx's reverse proxy. Usually something like git.<your server>.com";
    };

    appName = mkOption {
      type = types.string;
      description = "You guess what this does";
    };

    disableRegistration = mkOption {
      type = types.bool;
      default = true;
      description = "Turn this off just to create the first admin account";
    };
  };

  config = mkIf cfg.enable {
    services = {
      nginx = {
        virtualHosts."${cfg.virtualHost}" = {
          enableACME = true;
          forceSSL = true;
          locations."/".proxyPass = "http://localhost:9170";
        };
      };

      forgejo = {
        enable = true;
        lfs.enable = true;
        useWizard = false;
        settings = {
          general.APP_NAME = "${cfg.appName}";
          ui.DEFAULT_THEME = "forgejo-dark";
          server = {
            DOMAIN = "${cfg.virtualHost}";
            ROOT_URL = "https://${cfg.virtualHost}";
            HTTP_PORT = 9170;
            LANDING_PAGE = "explore";
          };

          service.DISABLE_REGISTRATION = ${cfg.disableRegistration};

          actions = {
            ENABLED = true;
          };
          mailer = {
            ENABLED = false;
          };
        };
      };
    };
  };
}