aboutsummaryrefslogtreecommitdiff
path: root/systems/eldiron/websites/git/default.nix
blob: 46ba34dff95ca5c61ad38665d980704b399432c0 (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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
{ lib, pkgs, config, ... }:
let
    mantisbt = pkgs.callPackage ./mantisbt.nix {
      mantisbt_2 = pkgs.webapps-mantisbt_2;
      mantisbt_2-plugins = pkgs.webapps-mantisbt_2-plugins;
      env = config.myEnv.tools.mantisbt;
      inherit config;
    };
    gitweb = pkgs.callPackage ./gitweb.nix {
      gitoliteDir = config.myServices.gitolite.gitoliteDir;
    };

    cfg = config.myServices.websites.tools.git;
in {
  options.myServices.websites.tools.git = {
    enable = lib.mkEnableOption "enable git's website";
  };

  config = lib.mkIf cfg.enable {
    myServices.chatonsProperties.services.mantisbt = {
      file.datetime = "2022-08-21T10:08:00";
      service = {
        name = "MantisBT";
        description = "Mantis Bug Tracker";
        website = "https://git.immae.eu/mantisbt";
        logo = "https://git.immae.eu/mantisbt/images/favicon.ico";
        status.level = "OK";
        status.description = "OK";
        registration."" = ["MEMBER" "CLIENT"];
        registration.load = "OPEN";
        install.type = "PACKAGE";
        guide.user = "https://www.immae.eu/docs/forge-logicielle.html";
      };
      software = {
        name = "MantisBT";
        website = "https://mantisbt.org/";
        license.url = "https://opensource.org/licenses/gpl-license";
        license.name = "GNU General Public License";
        version = mantisbt.webRoot.version;
        source.url = "https://github.com/mantisbt/mantisbt";
        modules = mantisbt.webRoot.pluginNames;
      };
    };
    secrets.keys = mantisbt.keys;
    services.websites.env.tools.modules =
      gitweb.apache.modules ++
      mantisbt.apache.modules;

    security.acme.certs.eldiron.extraDomainNames = [ "git.immae.eu" ];
    services.websites.env.tools.vhostConfs.git = {
      certName    = "eldiron";
      hosts       = ["git.immae.eu" ];
      root        = gitweb.apache.root;
      extraConfig = [
        gitweb.apache.vhostConf
        (mantisbt.apache.vhostConf config.services.phpfpm.pools.mantisbt.socket)
        ''
          RewriteEngine on
          RewriteCond %{REQUEST_URI}       ^/releases
          RewriteRule /releases(.*)        https://release.immae.eu$1 [P,L]
          ''
      ];
    };
    services.phpfpm.pools = {
      mantisbt = {
        user = config.services.websites.env.tools.user;
        group = config.services.websites.env.tools.group;
        settings = mantisbt.phpFpm.pool;
        phpPackage = pkgs.php72.withExtensions({ enabled, all }: enabled ++ [all.redis]);
      };
    };

    myServices.monitoring.fromMasterActivatedPlugins = [ "http" ];
    myServices.monitoring.fromMasterObjects.service = [
      {
        service_description = "gitweb website is running on git.immae.eu";
        host_name = config.hostEnv.fqdn;
        use = "external-web-service";
        check_command = ["check_https" "git.immae.eu" "/cgit" "<title>Immae’s git"];

        servicegroups = "webstatus-webapps";
        _webstatus_name = "Git";
        _webstatus_url = "https://git.immae.eu/";
      }

      {
        service_description = "mantisbt website is running on git.immae.eu";
        host_name = config.hostEnv.fqdn;
        use = "external-web-service";
        check_command = ["check_https" "git.immae.eu" "/mantisbt/" "<title>My View - MantisBT"];

        servicegroups = "webstatus-webapps";
        _webstatus_name = "Mantisbt";
        _webstatus_url = "https://git.immae.eu/mantisbt";
      }
    ];
  };
}