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