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






                                                                                                   
 












                                                                             



                                                      
                                 


         





                                                                                           
 
                                                                                          
                                                                                          



                                                                                                  



                                                                                  
                                                      

                                                               


                                                                            
 
                                                                                        
                                                                                        



                                                                                                
                                                                                                      



                                                                                  
                                                     

                                                              


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

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

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

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

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

      services.myPhpfpm.poolConfigs.ludivinecassal_dev = ludivinecassal_dev.phpFpm.pool;
      system.activationScripts.ludivinecassal_dev = ludivinecassal_dev.activationScript;
      system.extraSystemBuilderCmds = ''
        mkdir -p $out/webapps
        ln -s ${ludivinecassal_dev.webRoot} $out/webapps/${ludivinecassal_dev.apache.webappName}
        '';
      services.myWebsites.apacheConfig.ludivinecassal_dev.modules = ludivinecassal_dev.apache.modules;
      services.myWebsites.integration.modules = ludivinecassal_dev.apache.modules;
      services.myWebsites.integration.vhostConfs.ludivine = {
        certName    = "eldiron";
        hosts       = [ "ludivine.immae.eu" ];
        root        = ludivinecassal_dev.apache.root;
        extraConfig = [ ludivinecassal_dev.apache.vhostConf ];
      };
    })
  ];
}