]> git.immae.eu Git - perso/Immae/Config/Nix.git/blob - modules/private/websites/piedsjaloux/production.nix
Upgrade nixos
[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 "pm" = "dynamic";
32 "pm.max_children" = "20";
33 "pm.start_servers" = "2";
34 "pm.min_spare_servers" = "1";
35 "pm.max_spare_servers" = "3";
36 };
37 phpEnv = {
38 PATH = lib.makeBinPath [ pkgs.apg pkgs.unzip ];
39 };
40 phpWatchFiles = [
41 config.secrets.fullPaths."webapps/${app.environment}-piedsjaloux"
42 ];
43 };
44
45 secrets.keys = [
46 {
47 dest = "webapps/${app.environment}-piedsjaloux";
48 user = config.services.httpd.Prod.user;
49 group = config.services.httpd.Prod.group;
50 permissions = "0400";
51 text = ''
52 # This file is auto-generated during the composer install
53 parameters:
54 database_host: ${secrets.mysql.host}
55 database_port: ${secrets.mysql.port}
56 database_name: ${secrets.mysql.database}
57 database_user: ${secrets.mysql.user}
58 database_password: ${secrets.mysql.password}
59 database_server_version: ${pkgs.mariadb.mysqlVersion}
60 mailer_transport: smtp
61 mailer_host: 127.0.0.1
62 mailer_user: null
63 mailer_password: null
64 secret: ${secrets.secret}
65 pdflatex: "${pkgs.texlive.combine { inherit (pkgs.texlive) attachfile preprint scheme-small; }}/bin/pdflatex"
66 leapt_im:
67 binary_path: ${pkgs.imagemagick}/bin
68 '';
69 }
70 ];
71
72 services.websites.env.production.vhostConfs.piedsjaloux_prod = {
73 certName = "piedsjaloux";
74 certMainHost = "piedsjaloux.fr";
75 hosts = [ "piedsjaloux.fr" "www.piedsjaloux.fr" ];
76 root = pcfg.webappDirs.piedsjaloux_prod;
77 extraConfig = [
78 ''
79 RewriteEngine on
80 RewriteCond "%{HTTP_HOST}" "!^www.piedsjaloux\.fr$" [NC]
81 RewriteRule ^(.+)$ https://www.piedsjaloux.fr$1 [R=302,L]
82
83 <FilesMatch "\.php$">
84 SetHandler "proxy:unix:${pcfg.phpListenPaths.piedsjaloux_prod}|fcgi://localhost"
85 </FilesMatch>
86
87 Use Stats piedsjaloux.fr
88
89 <Directory ${pcfg.webappDirs.piedsjaloux_prod}>
90 Options Indexes FollowSymLinks MultiViews Includes
91 AllowOverride All
92 Require all granted
93 </Directory>
94 ''
95 ];
96 };
97 };
98 }