]> git.immae.eu Git - perso/Immae/Config/Nix.git/blob - modules/private/websites/chloe/production.nix
578bf918cab22fecc52798a546560d1d731a3965
[perso/Immae/Config/Nix.git] / modules / private / websites / chloe / production.nix
1 { lib, pkgs, config, ... }:
2 let
3 chloe = pkgs.callPackage ./builder.nix {
4 inherit (pkgs.webapps) chloe;
5 config = config.myEnv.websites.chloe.production;
6 apacheUser = config.services.httpd.Prod.user;
7 apacheGroup = config.services.httpd.Prod.group;
8 };
9
10 cfg = config.myServices.websites.chloe.production;
11 in {
12 options.myServices.websites.chloe.production.enable = lib.mkEnableOption "enable Chloe's website in production";
13
14 config = lib.mkIf cfg.enable {
15 services.duplyBackup.profiles.chloe_prod.rootDir = chloe.app.varDir;
16 secrets.keys = chloe.keys;
17 services.webstats.sites = [ { name = "osteopathe-cc.fr"; } ];
18
19 systemd.services.phpfpm-chloe_prod.after = lib.mkAfter chloe.phpFpm.serviceDeps;
20 systemd.services.phpfpm-chloe_prod.wants = chloe.phpFpm.serviceDeps;
21 services.phpfpm.pools.chloe_prod = {
22 listen = chloe.phpFpm.socket;
23 extraConfig = chloe.phpFpm.pool;
24 phpOptions = config.services.phpfpm.phpOptions + ''
25 extension=${pkgs.php}/lib/php/extensions/mysqli.so
26 '';
27 };
28 system.activationScripts.chloe_prod = chloe.activationScript;
29 myServices.websites.webappDirs."${chloe.apache.webappName}" = chloe.app.webRoot;
30 services.websites.env.production.modules = chloe.apache.modules;
31 services.websites.env.production.vhostConfs.chloe = {
32 certName = "chloe";
33 certMainHost = "osteopathe-cc.fr";
34 hosts = ["osteopathe-cc.fr" "www.osteopathe-cc.fr" ];
35 root = chloe.apache.root;
36 extraConfig = [
37 ''
38 RewriteEngine On
39 RewriteCond "%{HTTP_HOST}" "!^www\.osteopathe-cc\.fr$" [NC]
40 RewriteRule ^(.+)$ https://www.osteopathe-cc.fr$1 [R=302,L]
41 ''
42 chloe.apache.vhostConf
43 ];
44 };
45 services.websites.env.production.watchPaths = [
46 "/var/secrets/webapps/${chloe.app.environment}-chloe"
47 ];
48 };
49 }