]> git.immae.eu Git - perso/Immae/Config/Nix.git/blob - modules/private/websites/piedsjaloux/production.nix
e4e29c710d29f2ce242088e8f99ffca17dfeea04
[perso/Immae/Config/Nix.git] / modules / private / websites / piedsjaloux / production.nix
1 { lib, pkgs, config, ... }:
2 let
3 secrets = config.myEnv.websites.piedsjaloux.production;
4 app = pkgs.webapps.piedsjaloux.override { environment = secrets.environment; };
5 cfg = config.myServices.websites.piedsjaloux.production;
6 pcfg = config.services.phpApplication;
7 in {
8 options.myServices.websites.piedsjaloux.production.enable = lib.mkEnableOption "enable PiedsJaloux's website in production";
9
10 config = lib.mkIf cfg.enable {
11 services.duplyBackup.profiles.piedsjaloux_prod.rootDir = app.varDir;
12 services.webstats.sites = [ { name = "piedsjaloux.fr"; } ];
13 services.phpApplication.apps.piedsjaloux_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 "tmp" = "0700";
20 };
21 inherit app;
22 serviceDeps = [ "mysql.service" ];
23 preStartActions = [
24 "./bin/console --env=${app.environment} cache:clear --no-warmup"
25 ];
26 phpOpenbasedir = [ "/tmp" ];
27 phpPool = ''
28 php_admin_value[upload_max_filesize] = 20M
29 php_admin_value[post_max_size] = 20M
30 ;php_admin_flag[log_errors] = on
31 env[PATH] = ${lib.makeBinPath [ pkgs.apg pkgs.unzip ]}
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}-piedsjaloux"
40 ];
41 };
42
43 secrets.keys = [
44 {
45 dest = "webapps/${app.environment}-piedsjaloux";
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.database}
55 database_user: ${secrets.mysql.user}
56 database_password: ${secrets.mysql.password}
57 database_server_version: ${pkgs.mariadb.mysqlVersion}
58 mailer_transport: smtp
59 mailer_host: 127.0.0.1
60 mailer_user: null
61 mailer_password: null
62 secret: ${secrets.secret}
63 pdflatex: "${pkgs.texlive.combine { inherit (pkgs.texlive) attachfile preprint scheme-small; }}/bin/pdflatex"
64 leapt_im:
65 binary_path: ${pkgs.imagemagick}/bin
66 '';
67 }
68 ];
69
70 services.websites.env.production.vhostConfs.piedsjaloux_prod = {
71 certName = "piedsjaloux";
72 certMainHost = "piedsjaloux.fr";
73 hosts = [ "piedsjaloux.fr" "www.piedsjaloux.fr" ];
74 root = pcfg.webappDirs.piedsjaloux_prod;
75 extraConfig = [
76 ''
77 RewriteEngine on
78 RewriteCond "%{HTTP_HOST}" "!^www.piedsjaloux\.fr$" [NC]
79 RewriteRule ^(.+)$ https://www.piedsjaloux.fr$1 [R=302,L]
80
81 <FilesMatch "\.php$">
82 SetHandler "proxy:unix:${pcfg.phpListenPaths.piedsjaloux_prod}|fcgi://localhost"
83 </FilesMatch>
84
85 Use Stats piedsjaloux.fr
86
87 <Directory ${pcfg.webappDirs.piedsjaloux_prod}>
88 Options Indexes FollowSymLinks MultiViews Includes
89 AllowOverride All
90 Require all granted
91 </Directory>
92 ''
93 ];
94 };
95 };
96 }