aboutsummaryrefslogtreecommitdiff
path: root/modules/private/websites/isabelle/iridologie.nix
blob: ffbf2591f2bd107fe2c090a0d4d4222445bc6da1 (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
{ lib, pkgs, config,  ... }:
let
  iridologie = pkgs.callPackage ./spip_builder.nix {
    inherit (pkgs.webapps) iridologie;
    config = config.myEnv.websites.isabelle.iridologie;
    apacheUser = config.services.httpd.Prod.user;
    apacheGroup = config.services.httpd.Prod.group;
  };

  cfg = config.myServices.websites.isabelle.iridologie;
in {
  options.myServices.websites.isabelle.iridologie.enable = lib.mkEnableOption "enable Iridologie's website";

  config = lib.mkIf cfg.enable {
    services.duplyBackup.profiles.iridologie_prod.rootDir = iridologie.app.varDir;
    secrets.keys = iridologie.keys;
    services.webstats.sites = [ { name = "iridologie.icommandeur.org"; } ];

    systemd.services.phpfpm-iridologie.after = lib.mkAfter iridologie.phpFpm.serviceDeps;
    systemd.services.phpfpm-iridologie.wants = iridologie.phpFpm.serviceDeps;
    services.phpfpm.pools.iridologie = {
      user = config.services.httpd.Prod.user;
      group = config.services.httpd.Prod.group;
      settings = iridologie.phpFpm.pool;
      phpOptions = config.services.phpfpm.phpOptions + ''
        extension=${pkgs.php}/lib/php/extensions/mysqli.so
      '';
    };
    system.activationScripts.iridologie = iridologie.activationScript;
    myServices.websites.webappDirs."${iridologie.apache.webappName}" = iridologie.app.webRoot;
    services.websites.env.production.modules = iridologie.apache.modules;
    services.websites.env.production.vhostConfs.iridologie = {
      certName     = "aten";
      addToCerts   = true;
      hosts        = [ "iridologie.icommandeur.org" "icommandeur.org" "www.icommandeur.org" ];
      root         = iridologie.apache.root;
      extraConfig  = [
        ''
          RewriteEngine On
          RewriteCond "%{HTTP_HOST}" "!^iridologie\.icommandeur\.org$" [NC]
          RewriteRule ^(.+)$ https://iridologie.icommandeur.org$1 [R=302,L]
          ''
        (iridologie.apache.vhostConf config.services.phpfpm.pools.iridologie.socket)
      ];
    };
    services.websites.env.production.watchPaths = [
      "/var/secrets/webapps/${iridologie.app.environment}-iridologie"
    ];
  };
}