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