]> git.immae.eu Git - perso/Immae/Config/Nix.git/blame - modules/private/websites/isabelle/aten_production.nix
Remove overlay that overrides the php version
[perso/Immae/Config/Nix.git] / modules / private / websites / isabelle / aten_production.nix
CommitLineData
ab8f306d 1{ lib, pkgs, config, ... }:
f8026b6e 2let
829ef7f1 3 secrets = config.myEnv.websites.isabelle.aten_production;
d3452fc5 4 app = pkgs.callPackage ./aten_app {
dcac3ec7 5 composerEnv = pkgs.composerEnv.override { php = pkgs.php72; };
d3452fc5
IB
6 environment = secrets.environment;
7 varDir = "/var/lib/isabelle_aten_production";
8 };
829ef7f1 9 cfg = config.myServices.websites.isabelle.aten_production;
717ccfd9 10 pcfg = config.services.phpApplication;
f8026b6e 11in {
829ef7f1 12 options.myServices.websites.isabelle.aten_production.enable = lib.mkEnableOption "enable Aten's website in production";
f8026b6e
IB
13
14 config = lib.mkIf cfg.enable {
d3452fc5 15 services.duplyBackup.profiles.isabelle_aten_production.rootDir = app.varDir;
f8026b6e 16 services.webstats.sites = [ { name = "aten.pro"; } ];
d3452fc5 17 services.phpApplication.apps.isabelle_aten_production = {
717ccfd9
IB
18 websiteEnv = "production";
19 httpdUser = config.services.httpd.Prod.user;
20 httpdGroup = config.services.httpd.Prod.group;
21 httpdWatchFiles = [
d3452fc5 22 config.secrets.fullPaths."websites/isabelle/aten_production"
717ccfd9
IB
23 ];
24 inherit (app) webRoot varDir;
25 inherit app;
26 serviceDeps = [ "postgresql.service" ];
27 preStartActions = [
28 "APP_ENV=${app.environment} ./bin/console --env=${app.environment} cache:clear --no-warmup"
29 ];
30 phpOpenbasedir = [ "/tmp" ];
5400b9b6
IB
31 phpPool = {
32 "php_admin_value[upload_max_filesize]" = "20M";
33 "php_admin_value[post_max_size]" = "20M";
34 #"php_admin_flag[log_errors]" = "on";
35 "pm" = "dynamic";
36 "pm.max_children" = "20";
37 "pm.start_servers" = "2";
38 "pm.min_spare_servers" = "1";
39 "pm.max_spare_servers" = "3";
40 };
dcac3ec7 41 phpPackage = pkgs.php72;
717ccfd9 42 };
f8026b6e 43
717ccfd9 44 secrets.keys = [{
d3452fc5 45 dest = "websites/isabelle/aten_production";
717ccfd9 46 user = config.services.httpd.Prod.user;
9f66adf4 47 group = config.services.httpd.Prod.group;
717ccfd9 48 permissions = "0400";
ab8f306d
IB
49 text = let
50 # cf:
51 # https://secure.php.net/manual/fr/function.parse-url.php
52 # vendor/doctrine/dbal/lib/Doctrine/DBAL/DriverManager.php#parseDatabaseUrlQuery
53 psql_url = with secrets.postgresql; "pdo-pgsql://${user}:${password}@invalid:${port}/${database}?host=${socket}";
54 in ''
717ccfd9
IB
55 SetEnv APP_ENV "${app.environment}"
56 SetEnv APP_SECRET "${secrets.secret}"
ab8f306d 57 SetEnv DATABASE_URL "${psql_url}"
717ccfd9
IB
58 '';
59 }];
d3452fc5
IB
60 services.websites.env.production.vhostConfs.isabelle_aten_production = {
61 certName = "isabelle";
f8026b6e 62 certMainHost = "aten.pro";
717ccfd9 63 hosts = [ "aten.pro" "www.aten.pro" ];
d3452fc5 64 root = pcfg.webappDirs.isabelle_aten_production;
717ccfd9
IB
65 extraConfig = [
66 ''
67 <FilesMatch "\.php$">
d3452fc5 68 SetHandler "proxy:unix:${pcfg.phpListenPaths.isabelle_aten_production}|fcgi://localhost"
717ccfd9
IB
69 </FilesMatch>
70
d3452fc5 71 Include ${config.secrets.fullPaths."websites/isabelle/aten_production"}
717ccfd9
IB
72
73 Use Stats aten.pro
74
75 <Location /backend>
76 Use LDAPConnect
77 Require ldap-group cn=aten.pro,cn=httpd,ou=services,dc=immae,dc=eu
78 ErrorDocument 401 "<html><meta http-equiv=\"refresh\" content=\"0;url=https://aten.pro\"></html>"
79 </Location>
80
d3452fc5 81 <Directory ${pcfg.webappDirs.isabelle_aten_production}>
717ccfd9
IB
82 Options Indexes FollowSymLinks MultiViews Includes
83 AllowOverride All
84 Require all granted
85 DirectoryIndex index.php
86 FallbackResource /index.php
87 </Directory>
88 ''
89 ];
f8026b6e
IB
90 };
91 };
92}