]> git.immae.eu Git - perso/Immae/Config/Nix.git/blob - modules/private/websites/ludivine/production.nix
47450c54c249f8a90ab2421dc272260a10235c6f
[perso/Immae/Config/Nix.git] / modules / private / websites / ludivine / production.nix
1 { lib, pkgs, config, ... }:
2 let
3 secrets = config.myEnv.websites.ludivine.production;
4 app = pkgs.callPackage ./app {
5 environment = secrets.environment;
6 varDir = "/var/lib/ludivine_production";
7 secretsPath = config.secrets.fullPaths."websites/ludivine/production";
8 };
9 pcfg = config.services.phpApplication;
10 cfg = config.myServices.websites.ludivine.production;
11 in {
12 options.myServices.websites.ludivine.production.enable = lib.mkEnableOption "enable Ludivine's website in production";
13
14 config = lib.mkIf cfg.enable {
15 services.duplyBackup.profiles.ludivine_production.rootDir = app.varDir;
16 services.webstats.sites = [ { name = "ludivinecassal.com"; } ];
17 services.phpApplication.apps.ludivine_production = {
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" ];
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 };
41 phpWatchFiles = [
42 config.secrets.fullPaths."websites/ludivine/production"
43 ];
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 };
51 };
52
53 secrets.keys = [
54 {
55 dest = "websites/ludivine/production";
56 user = config.services.httpd.Prod.user;
57 group = config.services.httpd.Prod.group;
58 permissions = "0400";
59 text = ''
60 # This file is auto-generated during the composer install
61 parameters:
62 database_host: ${secrets.mysql.host}
63 database_port: ${secrets.mysql.port}
64 database_name: ${secrets.mysql.database}
65 database_user: ${secrets.mysql.user}
66 database_password: ${secrets.mysql.password}
67 database_server_version: ${pkgs.mariadb.mysqlVersion}
68 mailer_transport: smtp
69 mailer_host: 127.0.0.1
70 mailer_user: null
71 mailer_password: null
72 secret: ${secrets.secret}
73 ldap_host: ldap.immae.eu
74 ldap_port: 636
75 ldap_version: 3
76 ldap_ssl: true
77 ldap_tls: false
78 ldap_user_bind: 'uid={username},ou=users,dc=immae,dc=eu'
79 ldap_base_dn: 'dc=immae,dc=eu'
80 ldap_search_dn: '${secrets.ldap.dn}'
81 ldap_search_password: '${secrets.ldap.password}'
82 ldap_search_filter: '${secrets.ldap.filter}'
83 leapt_im:
84 binary_path: ${pkgs.imagemagick}/bin
85 assetic:
86 sass: ${pkgs.sass}/bin/sass
87 ruby: ${pkgs.ruby}/bin/ruby
88 '';
89 }
90 ];
91
92 services.websites.env.production.vhostConfs.ludivine_production = {
93 certName = "ludivine";
94 certMainHost = "ludivinecassal.com";
95 hosts = ["ludivinecassal.com" "www.ludivinecassal.com" ];
96 root = pcfg.webappDirs.ludivine_production;
97 extraConfig = [
98 ''
99 RewriteEngine on
100 RewriteCond "%{HTTP_HOST}" "!^ludivinecassal\.com$" [NC]
101 RewriteRule ^(.+)$ https://ludivinecassal.com$1 [R=302,L]
102
103 <FilesMatch "\.php$">
104 SetHandler "proxy:unix:${pcfg.phpListenPaths.ludivine_production}|fcgi://localhost"
105 </FilesMatch>
106
107 Use Stats ludivinecassal.com
108
109 <Directory ${pcfg.webappDirs.ludivine_production}>
110 Options Indexes FollowSymLinks MultiViews Includes
111 AllowOverride All
112 Require all granted
113 </Directory>
114 ''
115 ];
116 };
117 };
118 }