]>
Commit | Line | Data |
---|---|---|
ab8f306d | 1 | { lib, pkgs, config, ... }: |
f8026b6e | 2 | let |
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 | 12 | in { |
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; |
f8026b6e | 17 | services.webstats.sites = [ { name = "ludivinecassal.com"; } ]; |
d3452fc5 | 18 | services.phpApplication.apps.ludivine_production = { |
8164ed90 IB |
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" ]; | |
5400b9b6 IB |
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 | }; | |
8164ed90 | 42 | phpWatchFiles = [ |
d3452fc5 | 43 | config.secrets.fullPaths."websites/ludivine/production" |
8164ed90 | 44 | ]; |
d3452fc5 IB |
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 | }; | |
dcac3ec7 | 52 | phpPackage = pkgs.php72; |
8164ed90 IB |
53 | }; |
54 | ||
55 | secrets.keys = [ | |
56 | { | |
d3452fc5 | 57 | dest = "websites/ludivine/production"; |
8164ed90 IB |
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} | |
ab8f306d | 66 | database_name: ${secrets.mysql.database} |
8164ed90 IB |
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}' | |
ab8f306d | 84 | ldap_search_filter: '${secrets.ldap.filter}' |
8164ed90 IB |
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 | ]; | |
f8026b6e | 93 | |
d3452fc5 IB |
94 | services.websites.env.production.vhostConfs.ludivine_production = { |
95 | certName = "ludivine"; | |
f8026b6e IB |
96 | certMainHost = "ludivinecassal.com"; |
97 | hosts = ["ludivinecassal.com" "www.ludivinecassal.com" ]; | |
d3452fc5 | 98 | root = pcfg.webappDirs.ludivine_production; |
8164ed90 IB |
99 | extraConfig = [ |
100 | '' | |
33b5010f IB |
101 | RewriteEngine on |
102 | RewriteCond "%{HTTP_HOST}" "!^ludivinecassal\.com$" [NC] | |
103 | RewriteRule ^(.+)$ https://ludivinecassal.com$1 [R=302,L] | |
104 | ||
8164ed90 | 105 | <FilesMatch "\.php$"> |
d3452fc5 | 106 | SetHandler "proxy:unix:${pcfg.phpListenPaths.ludivine_production}|fcgi://localhost" |
8164ed90 IB |
107 | </FilesMatch> |
108 | ||
109 | Use Stats ludivinecassal.com | |
110 | ||
d3452fc5 | 111 | <Directory ${pcfg.webappDirs.ludivine_production}> |
8164ed90 IB |
112 | Options Indexes FollowSymLinks MultiViews Includes |
113 | AllowOverride All | |
114 | Require all granted | |
115 | </Directory> | |
116 | '' | |
117 | ]; | |
17f6eae9 | 118 | }; |
f8026b6e IB |
119 | }; |
120 | } |