]> git.immae.eu Git - perso/Immae/Config/Nix.git/blame - modules/private/websites/connexionswing/production.nix
Add alternate cloud storage for daily backups
[perso/Immae/Config/Nix.git] / modules / private / websites / connexionswing / production.nix
CommitLineData
ab8f306d 1{ lib, pkgs, config, ... }:
f8026b6e 2let
ab8f306d 3 secrets = config.myEnv.websites.connexionswing.production;
d3452fc5 4 app = pkgs.callPackage ./app {
dcac3ec7 5 composerEnv = pkgs.composerEnv.override { php = pkgs.php72; };
d3452fc5
IB
6 environment = secrets.environment;
7 varDir = "/var/lib/connexionswing_production";
8 secretsPath = config.secrets.fullPaths."websites/connexionswing/production";
9 };
f8026b6e 10 cfg = config.myServices.websites.connexionswing.production;
8164ed90 11 pcfg = config.services.phpApplication;
f8026b6e
IB
12in {
13 options.myServices.websites.connexionswing.production.enable = lib.mkEnableOption "enable Connexionswing's website in production";
14
15 config = lib.mkIf cfg.enable {
aeb9dd1e 16 services.duplyBackup.profiles.connexionswing_production.rootDir = app.varDir;
5a61f6ad 17 services.duplyBackup.profiles.connexionswing_production.remotes = ["eriomem" "ovh"];
f8026b6e 18 services.webstats.sites = [ { name = "connexionswing.com"; } ];
d3452fc5 19 services.phpApplication.apps.connexionswing_production = {
8164ed90
IB
20 websiteEnv = "production";
21 httpdUser = config.services.httpd.Prod.user;
22 httpdGroup = config.services.httpd.Prod.group;
23 inherit (app) webRoot varDir;
24 varDirPaths = {
25 "medias" = "0700";
26 "uploads" = "0700";
27 "var" = "0700";
28 };
29 inherit app;
30 serviceDeps = [ "mysql.service" ];
31 preStartActions = [
32 "./bin/console --env=${app.environment} cache:clear --no-warmup"
33 ];
34 phpOpenbasedir = [ "/tmp" "/run/wrappers/bin/sendmail" ];
5400b9b6
IB
35 phpPool = {
36 "php_admin_value[upload_max_filesize]" = "20M";
37 "php_admin_value[post_max_size]" = "20M";
38 #"php_admin_flag[log_errors]" = "on";
39 "pm" = "dynamic";
40 "pm.max_children" = "20";
41 "pm.start_servers" = "2";
42 "pm.min_spare_servers" = "1";
43 "pm.max_spare_servers" = "3";
44 };
8164ed90 45 phpWatchFiles = [
d3452fc5 46 config.secrets.fullPaths."websites/connexionswing/production"
8164ed90 47 ];
dcac3ec7 48 phpPackage = pkgs.php72;
f40f5b23 49 };
8164ed90
IB
50
51 secrets.keys = [
52 {
d3452fc5 53 dest = "websites/connexionswing/production";
8164ed90
IB
54 user = config.services.httpd.Prod.user;
55 group = config.services.httpd.Prod.group;
56 permissions = "0400";
57 text = ''
58 # This file is auto-generated during the composer install
59 parameters:
60 database_host: ${secrets.mysql.host}
61 database_port: ${secrets.mysql.port}
ab8f306d 62 database_name: ${secrets.mysql.database}
8164ed90
IB
63 database_user: ${secrets.mysql.user}
64 database_password: ${secrets.mysql.password}
65 database_server_version: ${pkgs.mariadb.mysqlVersion}
66 mailer_transport: sendmail
67 mailer_host: null
68 mailer_user: null
69 mailer_password: null
70 subscription_email: ${secrets.email}
71 allow_robots: true
72 secret: ${secrets.secret}
73 services:
74 swiftmailer.mailer.default.transport:
75 class: Swift_SendmailTransport
76 arguments: ['/run/wrappers/bin/sendmail -bs']
77 '';
78 }
79 ];
80
d3452fc5 81 services.websites.env.production.vhostConfs.connexionswing_production = {
f8026b6e
IB
82 certName = "connexionswing";
83 certMainHost = "connexionswing.com";
84 hosts = ["connexionswing.com" "sandetludo.com" "www.connexionswing.com" "www.sandetludo.com" ];
d3452fc5 85 root = pcfg.webappDirs.connexionswing_production;
8164ed90
IB
86 extraConfig = [
87 ''
88 <FilesMatch "\.php$">
d3452fc5 89 SetHandler "proxy:unix:${pcfg.phpListenPaths.connexionswing_production}|fcgi://localhost"
8164ed90
IB
90 </FilesMatch>
91
92 <Directory ${app.varDir}/medias>
93 Options FollowSymLinks
94 AllowOverride None
95 Require all granted
96 </Directory>
97
98 <Directory ${app.varDir}/uploads>
99 Options FollowSymLinks
100 AllowOverride None
101 Require all granted
102 </Directory>
103
104 Use Stats connexionswing.com
105
d3452fc5 106 <Directory ${pcfg.webappDirs.connexionswing_production}>
8164ed90
IB
107 Options Indexes FollowSymLinks MultiViews Includes
108 AllowOverride All
109 Require all granted
110 </Directory>
111 ''
112 ];
17f6eae9 113 };
f8026b6e
IB
114 };
115}