aboutsummaryrefslogtreecommitdiff
path: root/nixops/modules/websites/tools/dav/default.nix
blob: 5b5a0763b76c46fa34fd61eb0c238bc2559b9081 (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
{ lib, pkgs, config, myconfig,  ... }:
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 = myconfig.env.tools.davical;
      inherit (pkgs.webapps) davical awl;
    };

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

  config = lib.mkIf cfg.enable {
    security.acme.certs."eldiron".extraDomains."dav.immae.eu" = null;

    secrets.keys = davical.keys;
    services.myWebsites.tools.modules = davical.apache.modules;

    services.myWebsites.tools.vhostConfs.dav = {
      certName    = "eldiron";
      hosts       = ["dav.immae.eu" ];
      root        = null;
      extraConfig = [
        infcloud.vhostConf
        davical.apache.vhostConf
      ];
    };

    services.myPhpfpm.poolConfigs = {
      davical = davical.phpFpm.pool;
    };

    system.extraSystemBuilderCmds = ''
      mkdir -p $out/webapps
      ln -s ${davical.webRoot} $out/webapps/${davical.apache.webappName}
      ln -s ${pkgs.webapps.infcloud} $out/webapps/${infcloud.webappName}
      '';
  };
}