aboutsummaryrefslogtreecommitdiff
path: root/nixops/modules/websites/ludivine/default.nix
blob: c5a904b3da3722094b04d662bba0a3e10fd11835 (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
{ lib, pkgs, config, myconfig, mylibs, ... }:
let
    ludivinecassal = pkgs.callPackage ./ludivinecassal.nix { inherit (mylibs) fetchedGitPrivate; };
    ludivinecassal_dev  = ludivinecassal {
      config = myconfig.env.websites.ludivinecassal.integration;
    };
    ludivinecassal_prod = ludivinecassal {
      config = myconfig.env.websites.ludivinecassal.production;
    };

    cfg = config.services.myWebsites.Ludivine;
in {
  options.services.myWebsites.Ludivine = {
    production = {
      enable = lib.mkEnableOption "enable Ludivine's website in production";
    };
    integration = {
      enable = lib.mkEnableOption "enable Ludivine's website in integration";
    };
  };

  config = lib.mkMerge [
    (lib.mkIf cfg.production.enable {
      deployment.keys = ludivinecassal_prod.keys;
      services.myWebsites.commons.stats.enable = true;
      services.myWebsites.commons.stats.sites = [
        {
          name = "ludivinecassal.com";
          conf = ./goaccess.conf;
        }
      ];

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

      services.myPhpfpm.serviceDependencies.ludivinecassal_prod = ludivinecassal_prod.phpFpm.serviceDeps;
      services.myPhpfpm.poolConfigs.ludivinecassal_prod = ludivinecassal_prod.phpFpm.pool;
      system.activationScripts.ludivinecassal_prod = ludivinecassal_prod.activationScript;
      system.extraSystemBuilderCmds = ''
        mkdir -p $out/webapps
        ln -s ${ludivinecassal_prod.webRoot} $out/webapps/${ludivinecassal_prod.apache.webappName}
        '';
      services.myWebsites.production.modules = ludivinecassal_prod.apache.modules;
      services.myWebsites.production.vhostConfs.ludivine = {
        certName    = "ludivinecassal";
        hosts       = ["ludivinecassal.com" "www.ludivinecassal.com" ];
        root        = ludivinecassal_prod.apache.root;
        extraConfig = [ ludivinecassal_prod.apache.vhostConf ];
      };
    })
    (lib.mkIf cfg.integration.enable {
      deployment.keys = ludivinecassal_dev.keys;
      security.acme.certs."eldiron".extraDomains."ludivine.immae.eu" = null;

      services.myPhpfpm.serviceDependencies.ludivinecassal_dev = ludivinecassal_dev.phpFpm.serviceDeps;
      services.myPhpfpm.poolConfigs.ludivinecassal_dev = ludivinecassal_dev.phpFpm.pool;
      system.activationScripts.ludivinecassal_dev = ludivinecassal_dev.activationScript;
      system.extraSystemBuilderCmds = ''
        mkdir -p $out/webapps
        ln -s ${ludivinecassal_dev.webRoot} $out/webapps/${ludivinecassal_dev.apache.webappName}
        '';
      services.myWebsites.apacheConfig.ludivinecassal_dev.modules = ludivinecassal_dev.apache.modules;
      services.myWebsites.integration.modules = ludivinecassal_dev.apache.modules;
      services.myWebsites.integration.vhostConfs.ludivine = {
        certName    = "eldiron";
        hosts       = [ "ludivine.immae.eu" ];
        root        = ludivinecassal_dev.apache.root;
        extraConfig = [ ludivinecassal_dev.apache.vhostConf ];
      };
    })
  ];
}