aboutsummaryrefslogtreecommitdiff
path: root/nixops/modules/websites/aten/default.nix
blob: db2ab491fa14c76492f92f01c7c1f0156b8ba3f1 (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
{ 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;
      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.webRoot;
        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;
      services.myWebsites.integration.modules = aten_dev.apache.modules;
      services.myWebsites.integration.vhostConfs.aten = {
        certName    = "eldiron";
        hosts       = [ "dev.aten.pro" ];
        root        = aten_dev.webRoot;
        extraConfig = [ aten_dev.apache.vhostConf ];
      };
    })
  ];
}