]> git.immae.eu Git - perso/Immae/Config/Nix.git/blob - modules/private/websites/piedsjaloux/production.nix
9007f1906c2cdc4b332000b4839ebda268b2d86a
[perso/Immae/Config/Nix.git] / modules / private / websites / piedsjaloux / production.nix
1 { lib, pkgs, config, myconfig, ... }:
2 let
3 secrets = myconfig.env.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.webstats.sites = [ { name = "piedsjaloux.fr"; } ];
12 services.phpApplication.apps.piedsjaloux_prod = {
13 websiteEnv = "production";
14 httpdUser = config.services.httpd.Prod.user;
15 httpdGroup = config.services.httpd.Prod.group;
16 inherit (app) webRoot varDir;
17 varDirPaths = {
18 "tmp" = "0700";
19 };
20 inherit app;
21 serviceDeps = [ "mysql.service" ];
22 preStartActions = [
23 "./bin/console --env=${app.environment} cache:clear --no-warmup"
24 ];
25 phpOpenbasedir = [ "/tmp" ];
26 phpPool = ''
27 php_admin_value[upload_max_filesize] = 20M
28 php_admin_value[post_max_size] = 20M
29 ;php_admin_flag[log_errors] = on
30 env[PATH] = ${lib.makeBinPath [ pkgs.apg pkgs.unzip ]}
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 phpWatchFiles = [
38 config.secrets.fullPaths."webapps/${app.environment}-piedsjaloux"
39 ];
40 };
41
42 secrets.keys = [
43 {
44 dest = "webapps/${app.environment}-piedsjaloux";
45 user = config.services.httpd.Prod.user;
46 group = config.services.httpd.Prod.group;
47 permissions = "0400";
48 text = ''
49 # This file is auto-generated during the composer install
50 parameters:
51 database_host: ${secrets.mysql.host}
52 database_port: ${secrets.mysql.port}
53 database_name: ${secrets.mysql.name}
54 database_user: ${secrets.mysql.user}
55 database_password: ${secrets.mysql.password}
56 database_server_version: ${pkgs.mariadb.mysqlVersion}
57 mailer_transport: smtp
58 mailer_host: 127.0.0.1
59 mailer_user: null
60 mailer_password: null
61 secret: ${secrets.secret}
62 pdflatex: "${pkgs.texlive.combine { inherit (pkgs.texlive) attachfile preprint scheme-small; }}/bin/pdflatex"
63 leapt_im:
64 binary_path: ${pkgs.imagemagick}/bin
65 '';
66 }
67 ];
68
69 services.websites.env.production.vhostConfs.piedsjaloux_prod = {
70 certName = "piedsjaloux";
71 certMainHost = "piedsjaloux.fr";
72 hosts = [ "piedsjaloux.fr" "www.piedsjaloux.fr" ];
73 root = pcfg.webappDirs.piedsjaloux_prod;
74 extraConfig = [
75 ''
76 <FilesMatch "\.php$">
77 SetHandler "proxy:unix:${pcfg.phpListenPaths.piedsjaloux_prod}|fcgi://localhost"
78 </FilesMatch>
79
80 Use Stats piedsjaloux.fr
81
82 <Directory ${pcfg.webappDirs.piedsjaloux_prod}>
83 Options Indexes FollowSymLinks MultiViews Includes
84 AllowOverride All
85 Require all granted
86 </Directory>
87 ''
88 ];
89 };
90 };
91 }