aboutsummaryrefslogtreecommitdiff
path: root/nixops/modules/websites/aten/default.nix
blob: 58228ed08a0429368f38f65e0e1ccdea572336a0 (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
{ lib, pkgs, config, myconfig, mylibs, ... }:
let
    aten = pkgs.callPackage ./aten.nix { inherit (mylibs) fetchedGitPrivate yarn2nixPackage; };
    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 {
      deployment.keys = aten_prod.keys;
      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.serviceDependencies.aten_prod = aten_prod.phpFpm.serviceDeps;
      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 {
      deployment.keys = aten_dev.keys;
      security.acme.certs."eldiron".extraDomains."dev.aten.pro" = null;
      services.myPhpfpm.serviceDependencies.aten_dev = aten_dev.phpFpm.serviceDeps;
      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 ];
      };
    })
  ];
}