]> git.immae.eu Git - perso/Immae/Config/Nix.git/blame - modules/private/websites/piedsjaloux/production.nix
Use attrs for secrets instead of lists
[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;
5a61f6ad 18 services.duplyBackup.profiles.piedsjaloux_production.remotes = ["eriomem" "ovh"];
f8026b6e 19 services.webstats.sites = [ { name = "piedsjaloux.fr"; } ];
d3452fc5 20 services.phpApplication.apps.piedsjaloux_production = {
8164ed90
IB
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" ];
5400b9b6
IB
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 = {
d3452fc5
IB
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 ];
5400b9b6 51 };
8164ed90 52 phpWatchFiles = [
d3452fc5 53 app.secretsPath
8164ed90 54 ];
dcac3ec7 55 phpPackage = pkgs.php72;
8164ed90
IB
56 };
57
4c4652aa
IB
58 secrets.keys."websites/piedsjaloux/production" = {
59 user = config.services.httpd.Prod.user;
60 group = config.services.httpd.Prod.group;
61 permissions = "0400";
62 text = ''
63 # This file is auto-generated during the composer install
64 parameters:
65 database_host: ${secrets.mysql.host}
66 database_port: ${secrets.mysql.port}
67 database_name: ${secrets.mysql.database}
68 database_user: ${secrets.mysql.user}
69 database_password: ${secrets.mysql.password}
70 database_server_version: ${pkgs.mariadb.mysqlVersion}
71 mailer_transport: smtp
72 mailer_host: 127.0.0.1
73 mailer_user: null
74 mailer_password: null
75 secret: ${secrets.secret}
76 pdflatex: "${texlive}/bin/pdflatex"
77 leapt_im:
78 binary_path: ${pkgs.imagemagick}/bin
79 '';
80 };
f8026b6e 81
d3452fc5 82 services.websites.env.production.vhostConfs.piedsjaloux_production = {
f8026b6e
IB
83 certName = "piedsjaloux";
84 certMainHost = "piedsjaloux.fr";
85 hosts = [ "piedsjaloux.fr" "www.piedsjaloux.fr" ];
d3452fc5 86 root = pcfg.webappDirs.piedsjaloux_production;
8164ed90
IB
87 extraConfig = [
88 ''
33b5010f
IB
89 RewriteEngine on
90 RewriteCond "%{HTTP_HOST}" "!^www.piedsjaloux\.fr$" [NC]
91 RewriteRule ^(.+)$ https://www.piedsjaloux.fr$1 [R=302,L]
92
8164ed90 93 <FilesMatch "\.php$">
d3452fc5 94 SetHandler "proxy:unix:${pcfg.phpListenPaths.piedsjaloux_production}|fcgi://localhost"
8164ed90
IB
95 </FilesMatch>
96
97 Use Stats piedsjaloux.fr
98
d3452fc5 99 <Directory ${pcfg.webappDirs.piedsjaloux_production}>
8164ed90
IB
100 Options Indexes FollowSymLinks MultiViews Includes
101 AllowOverride All
102 Require all granted
103 </Directory>
104 ''
105 ];
f8026b6e
IB
106 };
107 };
108}