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