]> git.immae.eu Git - perso/Immae/Config/Nix.git/blob - modules/private/websites/piedsjaloux/production.nix
4b2c0561191c42dc328e2c6cb66151ef769e39d8
[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.callPackage ./app {
5 environment = secrets.environment;
6 varDir = "/var/lib/piedsjaloux_production";
7 secretsPath = config.secrets.fullPaths."websites/piedsjaloux/production";
8 };
9 cfg = config.myServices.websites.piedsjaloux.production;
10 pcfg = config.services.phpApplication;
11 texlive = pkgs.texlive.combine { inherit (pkgs.texlive) attachfile preprint scheme-small; };
12 in {
13 options.myServices.websites.piedsjaloux.production.enable = lib.mkEnableOption "enable PiedsJaloux's website in production";
14
15 config = lib.mkIf cfg.enable {
16 services.duplyBackup.profiles.piedsjaloux_production.rootDir = app.varDir;
17 services.webstats.sites = [ { name = "piedsjaloux.fr"; } ];
18 services.phpApplication.apps.piedsjaloux_production = {
19 websiteEnv = "production";
20 httpdUser = config.services.httpd.Prod.user;
21 httpdGroup = config.services.httpd.Prod.group;
22 inherit (app) webRoot varDir;
23 varDirPaths = {
24 "tmp" = "0700";
25 };
26 inherit app;
27 serviceDeps = [ "mysql.service" ];
28 preStartActions = [
29 "./bin/console --env=${app.environment} cache:clear --no-warmup"
30 ];
31 phpOpenbasedir = [ "/tmp" ];
32 phpPool = {
33 "php_admin_value[upload_max_filesize]" = "20M";
34 "php_admin_value[post_max_size]" = "20M";
35 #"php_admin_flag[log_errors]" = "on";
36 "pm" = "dynamic";
37 "pm.max_children" = "20";
38 "pm.start_servers" = "2";
39 "pm.min_spare_servers" = "1";
40 "pm.max_spare_servers" = "3";
41 };
42 phpEnv = {
43 PATH = lib.makeBinPath [
44 pkgs.apg pkgs.unzip
45 # below ones don't need to be in the PATH but they’re used in
46 # secrets
47 pkgs.imagemagick texlive
48 ];
49 };
50 phpWatchFiles = [
51 app.secretsPath
52 ];
53 };
54
55 secrets.keys = [
56 {
57 dest = "websites/piedsjaloux/production";
58 user = config.services.httpd.Prod.user;
59 group = config.services.httpd.Prod.group;
60 permissions = "0400";
61 text = ''
62 # This file is auto-generated during the composer install
63 parameters:
64 database_host: ${secrets.mysql.host}
65 database_port: ${secrets.mysql.port}
66 database_name: ${secrets.mysql.database}
67 database_user: ${secrets.mysql.user}
68 database_password: ${secrets.mysql.password}
69 database_server_version: ${pkgs.mariadb.mysqlVersion}
70 mailer_transport: smtp
71 mailer_host: 127.0.0.1
72 mailer_user: null
73 mailer_password: null
74 secret: ${secrets.secret}
75 pdflatex: "${texlive}/bin/pdflatex"
76 leapt_im:
77 binary_path: ${pkgs.imagemagick}/bin
78 '';
79 }
80 ];
81
82 services.websites.env.production.vhostConfs.piedsjaloux_production = {
83 certName = "piedsjaloux";
84 certMainHost = "piedsjaloux.fr";
85 hosts = [ "piedsjaloux.fr" "www.piedsjaloux.fr" ];
86 root = pcfg.webappDirs.piedsjaloux_production;
87 extraConfig = [
88 ''
89 RewriteEngine on
90 RewriteCond "%{HTTP_HOST}" "!^www.piedsjaloux\.fr$" [NC]
91 RewriteRule ^(.+)$ https://www.piedsjaloux.fr$1 [R=302,L]
92
93 <FilesMatch "\.php$">
94 SetHandler "proxy:unix:${pcfg.phpListenPaths.piedsjaloux_production}|fcgi://localhost"
95 </FilesMatch>
96
97 Use Stats piedsjaloux.fr
98
99 <Directory ${pcfg.webappDirs.piedsjaloux_production}>
100 Options Indexes FollowSymLinks MultiViews Includes
101 AllowOverride All
102 Require all granted
103 </Directory>
104 ''
105 ];
106 };
107 };
108 }