aboutsummaryrefslogtreecommitdiff
path: root/nixops/modules/websites/chloe/default.nix
blob: 8e801b59b2d918d3357919ec9ff96163fe42c145 (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
{ lib, pkgs, config, myconfig,  ... }:
let
  chloe_dev  = pkgs.callPackage ./chloe.nix {
    inherit (pkgs.webapps) chloe;
    config = myconfig.env.websites.chloe.integration;
  };
  chloe_prod = pkgs.callPackage ./chloe.nix {
    inherit (pkgs.webapps) 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"; } ];

      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.app.webRoot} $out/webapps/${chloe_prod.apache.webappName}
        '';
      services.websites.production.modules = chloe_prod.apache.modules;
      services.websites.production.vhostConfs.chloe = {
        certName     = "chloe";
        certMainHost = "osteopathe-cc.fr";
        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;
      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.app.webRoot} $out/webapps/${chloe_dev.apache.webappName}
        '';
      services.websites.integration.modules = chloe_dev.apache.modules;
      services.websites.integration.vhostConfs.chloe = {
        certName    = "eldiron";
        addToCerts  = true;
        hosts       = ["chloe.immae.eu" ];
        root        = chloe_dev.apache.root;
        extraConfig = [ chloe_dev.apache.vhostConf ];
      };
    })
  ];
}