aboutsummaryrefslogblamecommitdiff
path: root/nixops/modules/websites/connexionswing/default.nix
blob: c0036d8abcb9759d632ad37091490d86b856f2c2 (plain) (tree)
1
2
3
4
5
6
7
8
9
                                             
   






                                                                                                   
 










                                                                                   



                        

                                     
                                                



                                                      
                                 


         







                                                                                           
 
                                                                                           
                                                                                                         
                                                                                          
                                                                                                  
                                                                                          



                                                                                                  



                                                                                                             
                                                      

                                                               

                                      
                                               

                                                                                  
                                                                                         
                                                                                                       
                                                                                        
                                                                                                
                                                                                        



                                                                                                



                                                                                  
                                                     

                                                              



      
{ lib, pkgs, config, mylibs, myconfig, ... }:
let
    connexionswing = pkgs.callPackage ./connexionswing.nix { inherit (mylibs) fetchedGitPrivate; };
    connexionswing_dev  = connexionswing {
      config = myconfig.env.websites.connexionswing.integration;
    };
    connexionswing_prod = connexionswing {
      config = myconfig.env.websites.connexionswing.production;
    };

    cfg = config.services.myWebsites.Connexionswing;
in {
  options.services.myWebsites.Connexionswing = {
    production = {
      enable = lib.mkEnableOption "enable Connexionswing's website in production";
    };
    integration = {
      enable = lib.mkEnableOption "enable Connexionswing's website in integration";
    };
  };

  imports = [
    ../commons/stats.nix
  ];

  config = lib.mkMerge [
    (lib.mkIf cfg.production.enable {
      mySecrets.keys = connexionswing_prod.keys;
      services.myWebsites.commons.stats.enable = true;
      services.myWebsites.commons.stats.sites = [
        {
          name = "connexionswing.com";
          conf = ./goaccess.conf;
        }
      ];

      security.acme.certs."connexionswing" = config.services.myCertificates.certConfig // {
        domain = "connexionswing.com";
        extraDomains = {
          "www.connexionswing.com" = null;
          "sandetludo.com" = null;
          "www.sandetludo.com" = null;
        };
      };

      services.myPhpfpm.preStart.connexionswing_prod = connexionswing_prod.phpFpm.preStart;
      services.myPhpfpm.serviceDependencies.connexionswing_prod = connexionswing_prod.phpFpm.serviceDeps;
      services.myPhpfpm.poolConfigs.connexionswing_prod = connexionswing_prod.phpFpm.pool;
      services.myPhpfpm.poolPhpConfigs.connexionswing_prod = connexionswing_prod.phpFpm.phpConfig;
      system.activationScripts.connexionswing_prod = connexionswing_prod.activationScript;
      system.extraSystemBuilderCmds = ''
        mkdir -p $out/webapps
        ln -s ${connexionswing_prod.webRoot} $out/webapps/${connexionswing_prod.apache.webappName}
        '';
      services.myWebsites.production.modules = connexionswing_prod.apache.modules;
      services.myWebsites.production.vhostConfs.connexionswing = {
        certName    = "connexionswing";
        hosts       = ["connexionswing.com" "sandetludo.com" "www.connexionswing.com" "www.sandetludo.com" ];
        root        = connexionswing_prod.apache.root;
        extraConfig = [ connexionswing_prod.apache.vhostConf ];
      };
    })
    (lib.mkIf cfg.integration.enable {
      mySecrets.keys = connexionswing_dev.keys;
      security.acme.certs."eldiron".extraDomains."sandetludo.immae.eu" = null;
      security.acme.certs."eldiron".extraDomains."connexionswing.immae.eu" = null;
      services.myPhpfpm.preStart.connexionswing_dev = connexionswing_dev.phpFpm.preStart;
      services.myPhpfpm.serviceDependencies.connexionswing_dev = connexionswing_dev.phpFpm.serviceDeps;
      services.myPhpfpm.poolConfigs.connexionswing_dev = connexionswing_dev.phpFpm.pool;
      services.myPhpfpm.poolPhpConfigs.connexionswing_dev = connexionswing_dev.phpFpm.phpConfig;
      system.activationScripts.connexionswing_dev = connexionswing_dev.activationScript;
      system.extraSystemBuilderCmds = ''
        mkdir -p $out/webapps
        ln -s ${connexionswing_dev.webRoot} $out/webapps/${connexionswing_dev.apache.webappName}
        '';
      services.myWebsites.integration.modules = connexionswing_dev.apache.modules;
      services.myWebsites.integration.vhostConfs.connexionswing = {
        certName    = "eldiron";
        hosts       = ["connexionswing.immae.eu" "sandetludo.immae.eu" ];
        root        = connexionswing_dev.apache.root;
        extraConfig = [ connexionswing_dev.apache.vhostConf ];
      };
    })
  ];
}