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