aboutsummaryrefslogtreecommitdiff
path: root/nixops/modules/websites/connexionswing/default.nix
blob: c0036d8abcb9759d632ad37091490d86b856f2c2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
{ 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 ];
      };
    })
  ];
}