aboutsummaryrefslogtreecommitdiff
path: root/modules/private/websites/tools/dav/default.nix
blob: f53cf5803567e16e1228a112662f49ac82458a95 (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
{ lib, pkgs, config,  ... }:
let
    infcloud = rec {
      webappName = "tools_infcloud";
      root = "/run/current-system/webapps/${webappName}";
      vhostConf = ''
          Alias /carddavmate ${root}
          Alias /caldavzap ${root}
          Alias /infcloud ${root}
          <Directory ${root}>
            AllowOverride All
            Options FollowSymlinks
            Require all granted
            DirectoryIndex index.html
          </Directory>
      '';
    };
    davical = pkgs.callPackage ./davical.nix {
      env = config.myEnv.tools.davical;
      inherit (pkgs.webapps) davical awl;
    };

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

  config = lib.mkIf cfg.enable {
    system.activationScripts.davical = davical.activationScript;
    secrets.keys = davical.keys;
    services.websites.env.tools.modules = davical.apache.modules;

    services.websites.env.tools.vhostConfs.dav = {
      certName    = "eldiron";
      addToCerts  = true;
      hosts       = ["dav.immae.eu" ];
      root        = "/run/current-system/webapps/_dav";
      extraConfig = [
        infcloud.vhostConf
        (davical.apache.vhostConf config.services.phpfpm.pools.davical.socket)
      ];
    };

    services.phpfpm.pools = {
      davical = {
        user = config.services.httpd.Tools.user;
        group = config.services.httpd.Tools.group;
        settings = davical.phpFpm.pool;
        phpPackage = pkgs.php72;
      };
    };

    services.websites.webappDirs._dav = ./www;
    services.websites.webappDirs."${davical.apache.webappName}" = davical.webRoot;
    services.websites.webappDirs."${infcloud.webappName}" = pkgs.webapps.infcloud;
  };
}