]> git.immae.eu Git - perso/Immae/Config/Nix.git/blame - modules/private/websites/piedsjaloux/production.nix
Remove overlay that overrides the php version
[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 {
d3452fc5 17 services.duplyBackup.profiles.piedsjaloux_production.rootDir = app.varDir;
f8026b6e 18 services.webstats.sites = [ { name = "piedsjaloux.fr"; } ];
d3452fc5 19 services.phpApplication.apps.piedsjaloux_production = {
8164ed90
IB
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" ];
5400b9b6
IB
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 = {
d3452fc5
IB
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 ];
5400b9b6 50 };
8164ed90 51 phpWatchFiles = [
d3452fc5 52 app.secretsPath
8164ed90 53 ];
dcac3ec7 54 phpPackage = pkgs.php72;
8164ed90
IB
55 };
56
57 secrets.keys = [
58 {
d3452fc5 59 dest = "websites/piedsjaloux/production";
8164ed90
IB
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}
ab8f306d 68 database_name: ${secrets.mysql.database}
8164ed90
IB
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}
d3452fc5 77 pdflatex: "${texlive}/bin/pdflatex"
8164ed90
IB
78 leapt_im:
79 binary_path: ${pkgs.imagemagick}/bin
80 '';
81 }
82 ];
f8026b6e 83
d3452fc5 84 services.websites.env.production.vhostConfs.piedsjaloux_production = {
f8026b6e
IB
85 certName = "piedsjaloux";
86 certMainHost = "piedsjaloux.fr";
87 hosts = [ "piedsjaloux.fr" "www.piedsjaloux.fr" ];
d3452fc5 88 root = pcfg.webappDirs.piedsjaloux_production;
8164ed90
IB
89 extraConfig = [
90 ''
33b5010f
IB
91 RewriteEngine on
92 RewriteCond "%{HTTP_HOST}" "!^www.piedsjaloux\.fr$" [NC]
93 RewriteRule ^(.+)$ https://www.piedsjaloux.fr$1 [R=302,L]
94
8164ed90 95 <FilesMatch "\.php$">
d3452fc5 96 SetHandler "proxy:unix:${pcfg.phpListenPaths.piedsjaloux_production}|fcgi://localhost"
8164ed90
IB
97 </FilesMatch>
98
99 Use Stats piedsjaloux.fr
100
d3452fc5 101 <Directory ${pcfg.webappDirs.piedsjaloux_production}>
8164ed90
IB
102 Options Indexes FollowSymLinks MultiViews Includes
103 AllowOverride All
104 Require all granted
105 </Directory>
106 ''
107 ];
f8026b6e
IB
108 };
109 };
110}