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