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






                                                                               
 










                                                                         



                        

                                     



                                                      
                                 


         





                                                                                 
 
                                                                      
                                                                      



                                                                              
                                                                                    



                                                                        
                                            

                                                     


                                                                       
                                                                    
                                                                    



                                                                            



                                                                        
                                           

                                                    



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

    cfg = config.services.myWebsites.Aten;
in {
  options.services.myWebsites.Aten = {
    production = {
      enable = lib.mkEnableOption "enable Aten's website in production";
    };
    integration = {
      enable = lib.mkEnableOption "enable Aten'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 = "aten.pro";
          conf = ./goaccess.conf;
        }
      ];

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

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