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