aboutsummaryrefslogblamecommitdiff
path: root/modules/private/websites/tools/dav/default.nix
blob: f53cf5803567e16e1228a112662f49ac82458a95 (plain) (tree)
1
2
                            
   














                                                         
                                              
                                       
                                         
      
 
                                               
    
                                           



                                                     
                                                                
                                
                                                                 
 
                                                  
                              
                         
                                      
                                                       
                     
                          
                                                                              


        

                             


                                                  
                                
        

      


                                                                                  


    
{ 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;
  };
}