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






                                                                                 
 












                                                                          
                                     
                                                                   
 





                                                                                  
 
                                                                                       
                                                                        


                                                          
                                                                        



                                                                                



                                                                         
                                             

                                                      

                                      
                                    
                                                                         
                                                                                     
                                                                      
                                                     

                                                          
                                                                      



                                                                              



                                                                         
                                            

                                                     


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

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

  config = lib.mkMerge [
    (lib.mkIf cfg.production.enable {
      secrets.keys = chloe_prod.keys;
      services.webstats.sites = [ { name = "osteopathe-cc.fr"; } ];

      security.acme.certs."chloe" = config.services.myCertificates.certConfig // {
        domain = "osteopathe-cc.fr";
        extraDomains = {
          "www.osteopathe-cc.fr" = null;
        };
      };

      services.myPhpfpm.serviceDependencies.chloe_prod = chloe_prod.phpFpm.serviceDeps;
      services.myPhpfpm.poolConfigs.chloe_prod = chloe_prod.phpFpm.pool;
      services.myPhpfpm.poolPhpConfigs.chloe_prod = ''
        extension=${pkgs.php}/lib/php/extensions/mysqli.so
        '';
      system.activationScripts.chloe_prod = chloe_prod.activationScript;
      system.extraSystemBuilderCmds = ''
        mkdir -p $out/webapps
        ln -s ${chloe_prod.webRoot} $out/webapps/${chloe_prod.apache.webappName}
        '';
      services.myWebsites.production.modules = chloe_prod.apache.modules;
      services.myWebsites.production.vhostConfs.chloe = {
        certName    = "chloe";
        hosts       = ["osteopathe-cc.fr" "www.osteopathe-cc.fr" ];
        root        = chloe_prod.apache.root;
        extraConfig = [ chloe_prod.apache.vhostConf ];
      };
    })
    (lib.mkIf cfg.integration.enable {
      secrets.keys = chloe_dev.keys;
      security.acme.certs."eldiron".extraDomains."chloe.immae.eu" = null;
      services.myPhpfpm.serviceDependencies.chloe_dev = chloe_dev.phpFpm.serviceDeps;
      services.myPhpfpm.poolConfigs.chloe_dev = chloe_dev.phpFpm.pool;
      services.myPhpfpm.poolPhpConfigs.chloe_dev = ''
        extension=${pkgs.php}/lib/php/extensions/mysqli.so
        '';
      system.activationScripts.chloe_dev = chloe_dev.activationScript;
      system.extraSystemBuilderCmds = ''
        mkdir -p $out/webapps
        ln -s ${chloe_dev.webRoot} $out/webapps/${chloe_dev.apache.webappName}
        '';
      services.myWebsites.integration.modules = chloe_dev.apache.modules;
      services.myWebsites.integration.vhostConfs.chloe = {
        certName    = "eldiron";
        hosts       = ["chloe.immae.eu" ];
        root        = chloe_dev.apache.root;
        extraConfig = [ chloe_dev.apache.vhostConf ];
      };
    })
  ];
}