]> git.immae.eu Git - perso/Immae/Config/Nix.git/blame - modules/private/websites/ludivine/production.nix
Remove duply-backup
[perso/Immae/Config/Nix.git] / modules / private / websites / ludivine / production.nix
CommitLineData
ab8f306d 1{ lib, pkgs, config, ... }:
f8026b6e 2let
d3452fc5
IB
3 secrets = config.myEnv.websites.ludivine.production;
4 app = pkgs.callPackage ./app {
dcac3ec7 5 composerEnv = pkgs.composerEnv.override { php = pkgs.php72; };
d3452fc5
IB
6 environment = secrets.environment;
7 varDir = "/var/lib/ludivine_production";
8 secretsPath = config.secrets.fullPaths."websites/ludivine/production";
9 };
8164ed90 10 pcfg = config.services.phpApplication;
d3452fc5 11 cfg = config.myServices.websites.ludivine.production;
f8026b6e 12in {
d3452fc5 13 options.myServices.websites.ludivine.production.enable = lib.mkEnableOption "enable Ludivine's website in production";
f8026b6e
IB
14
15 config = lib.mkIf cfg.enable {
f8026b6e 16 services.webstats.sites = [ { name = "ludivinecassal.com"; } ];
d3452fc5 17 services.phpApplication.apps.ludivine_production = {
8164ed90
IB
18 websiteEnv = "production";
19 httpdUser = config.services.httpd.Prod.user;
20 httpdGroup = config.services.httpd.Prod.group;
21 inherit (app) webRoot varDir;
22 varDirPaths = {
23 "tmp" = "0700";
24 };
25 inherit app;
26 serviceDeps = [ "mysql.service" ];
27 preStartActions = [
28 "./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 };
8164ed90 41 phpWatchFiles = [
d3452fc5 42 config.secrets.fullPaths."websites/ludivine/production"
8164ed90 43 ];
d3452fc5
IB
44 phpEnv = {
45 PATH = lib.makeBinPath [
46 # below ones don't need to be in the PATH but they’re used in
47 # secrets
48 pkgs.imagemagick pkgs.sass pkgs.ruby
49 ];
50 };
dcac3ec7 51 phpPackage = pkgs.php72;
8164ed90
IB
52 };
53
4c4652aa
IB
54 secrets.keys."websites/ludivine/production" = {
55 user = config.services.httpd.Prod.user;
56 group = config.services.httpd.Prod.group;
57 permissions = "0400";
58 text = ''
59 # This file is auto-generated during the composer install
60 parameters:
61 database_host: ${secrets.mysql.host}
62 database_port: ${secrets.mysql.port}
63 database_name: ${secrets.mysql.database}
64 database_user: ${secrets.mysql.user}
65 database_password: ${secrets.mysql.password}
66 database_server_version: ${pkgs.mariadb.mysqlVersion}
67 mailer_transport: smtp
68 mailer_host: 127.0.0.1
69 mailer_user: null
70 mailer_password: null
71 secret: ${secrets.secret}
72 ldap_host: ldap.immae.eu
73 ldap_port: 636
74 ldap_version: 3
75 ldap_ssl: true
76 ldap_tls: false
77 ldap_user_bind: 'uid={username},ou=users,dc=immae,dc=eu'
78 ldap_base_dn: 'dc=immae,dc=eu'
79 ldap_search_dn: '${secrets.ldap.dn}'
80 ldap_search_password: '${secrets.ldap.password}'
81 ldap_search_filter: '${secrets.ldap.filter}'
82 leapt_im:
83 binary_path: ${pkgs.imagemagick}/bin
84 assetic:
85 sass: ${pkgs.sass}/bin/sass
86 ruby: ${pkgs.ruby}/bin/ruby
87 '';
88 };
f8026b6e 89
d3452fc5
IB
90 services.websites.env.production.vhostConfs.ludivine_production = {
91 certName = "ludivine";
f8026b6e
IB
92 certMainHost = "ludivinecassal.com";
93 hosts = ["ludivinecassal.com" "www.ludivinecassal.com" ];
750fe5a4 94 root = app.webRoot;
8164ed90
IB
95 extraConfig = [
96 ''
33b5010f
IB
97 RewriteEngine on
98 RewriteCond "%{HTTP_HOST}" "!^ludivinecassal\.com$" [NC]
99 RewriteRule ^(.+)$ https://ludivinecassal.com$1 [R=302,L]
100
8164ed90 101 <FilesMatch "\.php$">
d3452fc5 102 SetHandler "proxy:unix:${pcfg.phpListenPaths.ludivine_production}|fcgi://localhost"
8164ed90
IB
103 </FilesMatch>
104
105 Use Stats ludivinecassal.com
106
750fe5a4 107 <Directory ${app.webRoot}>
8164ed90
IB
108 Options Indexes FollowSymLinks MultiViews Includes
109 AllowOverride All
110 Require all granted
111 </Directory>
112 ''
113 ];
17f6eae9 114 };
f8026b6e
IB
115 };
116}