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






                                                                                             
 










                                                                                
             
                        

    

                                     



                                                      
                                 


         





                                                                                        
 
                                                                                    
                                                                                    



                                                                                            



                                                                               
                                                   

                                                            


                                                                               
                                                                                  
                                                                                  



                                                                                          



                                                                               
                                                  

                                                           



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

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

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

  config = lib.mkMerge [
    (lib.mkIf cfg.production.enable {
      services.myWebsites.commons.stats.enable = true;
      services.myWebsites.commons.stats.sites = [
        {
          name = "piedsjaloux.fr";
          conf = ./goaccess.conf;
        }
      ];

      security.acme.certs."piedsjaloux" = config.services.myCertificates.certConfig // {
        domain = "piedsjaloux.fr";
        extraDomains = {
          "www.piedsjaloux.fr" = null;
        };
      };

      services.myPhpfpm.poolConfigs.piedsjaloux_prod = piedsjaloux_prod.phpFpm.pool;
      system.activationScripts.piedsjaloux_prod = piedsjaloux_prod.activationScript;
      system.extraSystemBuilderCmds = ''
        mkdir -p $out/webapps
        ln -s ${piedsjaloux_prod.webRoot} $out/webapps/${piedsjaloux_prod.apache.webappName}
        '';
      services.myWebsites.production.modules = piedsjaloux_prod.apache.modules;
      services.myWebsites.production.vhostConfs.piedsjaloux = {
        certName    = "piedsjaloux";
        hosts       = [ "piedsjaloux.fr" "www.piedsjaloux.fr" ];
        root        = piedsjaloux_prod.apache.root;
        extraConfig = [ piedsjaloux_prod.apache.vhostConf ];
      };
    })
    (lib.mkIf cfg.integration.enable {
      security.acme.certs."eldiron".extraDomains."piedsjaloux.immae.eu" = null;
      services.myPhpfpm.poolConfigs.piedsjaloux_dev = piedsjaloux_dev.phpFpm.pool;
      system.activationScripts.piedsjaloux_dev = piedsjaloux_dev.activationScript;
      system.extraSystemBuilderCmds = ''
        mkdir -p $out/webapps
        ln -s ${piedsjaloux_dev.webRoot} $out/webapps/${piedsjaloux_dev.apache.webappName}
        '';
      services.myWebsites.integration.modules = piedsjaloux_dev.apache.modules;
      services.myWebsites.integration.vhostConfs.piedsjaloux = {
        certName    = "eldiron";
        hosts       = [ "piedsjaloux.immae.eu" ];
        root        = piedsjaloux_dev.apache.root;
        extraConfig = [ piedsjaloux_dev.apache.vhostConf ];
      };
    })
  ];
}