]> git.immae.eu Git - perso/Immae/Config/Nix.git/blame - modules/private/websites/piedsjaloux/production.nix
Remove duply-backup
[perso/Immae/Config/Nix.git] / modules / private / websites / piedsjaloux / production.nix
CommitLineData
ab8f306d 1{ lib, pkgs, config, ... }:
f8026b6e 2let
ab8f306d 3 secrets = config.myEnv.websites.piedsjaloux.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/piedsjaloux_production";
8 secretsPath = config.secrets.fullPaths."websites/piedsjaloux/production";
9 };
f8026b6e 10 cfg = config.myServices.websites.piedsjaloux.production;
8164ed90 11 pcfg = config.services.phpApplication;
d3452fc5 12 texlive = pkgs.texlive.combine { inherit (pkgs.texlive) attachfile preprint scheme-small; };
f8026b6e
IB
13in {
14 options.myServices.websites.piedsjaloux.production.enable = lib.mkEnableOption "enable PiedsJaloux's website in production";
15
16 config = lib.mkIf cfg.enable {
f8026b6e 17 services.webstats.sites = [ { name = "piedsjaloux.fr"; } ];
d3452fc5 18 services.phpApplication.apps.piedsjaloux_production = {
8164ed90
IB
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" ];
5400b9b6
IB
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 = {
d3452fc5
IB
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 ];
5400b9b6 49 };
8164ed90 50 phpWatchFiles = [
d3452fc5 51 app.secretsPath
8164ed90 52 ];
dcac3ec7 53 phpPackage = pkgs.php72;
8164ed90
IB
54 };
55
4c4652aa
IB
56 secrets.keys."websites/piedsjaloux/production" = {
57 user = config.services.httpd.Prod.user;
58 group = config.services.httpd.Prod.group;
59 permissions = "0400";
60 text = ''
61 # This file is auto-generated during the composer install
62 parameters:
63 database_host: ${secrets.mysql.host}
64 database_port: ${secrets.mysql.port}
65 database_name: ${secrets.mysql.database}
66 database_user: ${secrets.mysql.user}
67 database_password: ${secrets.mysql.password}
68 database_server_version: ${pkgs.mariadb.mysqlVersion}
69 mailer_transport: smtp
70 mailer_host: 127.0.0.1
71 mailer_user: null
72 mailer_password: null
73 secret: ${secrets.secret}
74 pdflatex: "${texlive}/bin/pdflatex"
75 leapt_im:
76 binary_path: ${pkgs.imagemagick}/bin
77 '';
78 };
f8026b6e 79
d3452fc5 80 services.websites.env.production.vhostConfs.piedsjaloux_production = {
f8026b6e
IB
81 certName = "piedsjaloux";
82 certMainHost = "piedsjaloux.fr";
83 hosts = [ "piedsjaloux.fr" "www.piedsjaloux.fr" ];
750fe5a4 84 root = app.webRoot;
8164ed90
IB
85 extraConfig = [
86 ''
33b5010f
IB
87 RewriteEngine on
88 RewriteCond "%{HTTP_HOST}" "!^www.piedsjaloux\.fr$" [NC]
89 RewriteRule ^(.+)$ https://www.piedsjaloux.fr$1 [R=302,L]
90
8164ed90 91 <FilesMatch "\.php$">
d3452fc5 92 SetHandler "proxy:unix:${pcfg.phpListenPaths.piedsjaloux_production}|fcgi://localhost"
8164ed90
IB
93 </FilesMatch>
94
95 Use Stats piedsjaloux.fr
96
750fe5a4 97 <Directory ${app.webRoot}>
8164ed90
IB
98 Options Indexes FollowSymLinks MultiViews Includes
99 AllowOverride All
100 Require all granted
101 </Directory>
102 ''
103 ];
f8026b6e
IB
104 };
105 };
106}