aboutsummaryrefslogtreecommitdiff
path: root/modules/private/websites/ludivinecassal/production.nix
diff options
context:
space:
mode:
authorIsmaël Bouya <ismael.bouya@normalesup.org>2019-06-02 23:26:23 +0200
committerIsmaël Bouya <ismael.bouya@normalesup.org>2019-06-02 23:40:37 +0200
commit8164ed90c7fdd93fd035bce3dc1b3fc6bde9e30e (patch)
treec8f34a5f7ed6ac78d84c024a6a9e3dc847bbe8e5 /modules/private/websites/ludivinecassal/production.nix
parent9f66adf4372a3b1c859dc053489f727aa360077e (diff)
downloadNix-8164ed90c7fdd93fd035bce3dc1b3fc6bde9e30e.tar.gz
Nix-8164ed90c7fdd93fd035bce3dc1b3fc6bde9e30e.tar.zst
Nix-8164ed90c7fdd93fd035bce3dc1b3fc6bde9e30e.zip
Move production php application to dedicated module
Diffstat (limited to 'modules/private/websites/ludivinecassal/production.nix')
-rw-r--r--modules/private/websites/ludivinecassal/production.nix109
1 files changed, 87 insertions, 22 deletions
diff --git a/modules/private/websites/ludivinecassal/production.nix b/modules/private/websites/ludivinecassal/production.nix
index 9d8407d..82f6899 100644
--- a/modules/private/websites/ludivinecassal/production.nix
+++ b/modules/private/websites/ludivinecassal/production.nix
@@ -1,37 +1,102 @@
1{ lib, pkgs, config, myconfig, ... }: 1{ lib, pkgs, config, myconfig, ... }:
2let 2let
3 ludivinecassal = pkgs.callPackage ./builder.nix { 3 secrets = myconfig.env.websites.ludivinecassal.production;
4 inherit (pkgs.webapps) ludivinecassal; 4 app = pkgs.webapps.ludivinecassal.override { environment = secrets.environment; };
5 config = myconfig.env.websites.ludivinecassal.production; 5 pcfg = config.services.phpApplication;
6 apacheUser = config.services.httpd.Prod.user;
7 apacheGroup = config.services.httpd.Prod.group;
8 };
9
10 cfg = config.myServices.websites.ludivinecassal.production; 6 cfg = config.myServices.websites.ludivinecassal.production;
11in { 7in {
12 options.myServices.websites.ludivinecassal.production.enable = lib.mkEnableOption "enable Ludivine's website in production"; 8 options.myServices.websites.ludivinecassal.production.enable = lib.mkEnableOption "enable Ludivine's website in production";
13 9
14 config = lib.mkIf cfg.enable { 10 config = lib.mkIf cfg.enable {
15 secrets.keys = ludivinecassal.keys;
16 services.webstats.sites = [ { name = "ludivinecassal.com"; } ]; 11 services.webstats.sites = [ { name = "ludivinecassal.com"; } ];
12 services.phpApplication.apps.ludivinecassal_prod = {
13 websiteEnv = "production";
14 httpdUser = config.services.httpd.Prod.user;
15 httpdGroup = config.services.httpd.Prod.group;
16 inherit (app) webRoot varDir;
17 varDirPaths = {
18 "tmp" = "0700";
19 };
20 inherit app;
21 serviceDeps = [ "mysql.service" ];
22 preStartActions = [
23 "./bin/console --env=${app.environment} cache:clear --no-warmup"
24 ];
25 phpOpenbasedir = [ "/tmp" ];
26 phpPool = ''
27 php_admin_value[upload_max_filesize] = 20M
28 php_admin_value[post_max_size] = 20M
29 ;php_admin_flag[log_errors] = on
30 pm = dynamic
31 pm.max_children = 20
32 pm.start_servers = 2
33 pm.min_spare_servers = 1
34 pm.max_spare_servers = 3
35 '';
36 phpWatchFiles = [
37 config.secrets.fullPaths."webapps/${app.environment}-ludivinecassal"
38 ];
39 };
40
41 secrets.keys = [
42 {
43 dest = "webapps/${app.environment}-ludivinecassal";
44 user = config.services.httpd.Prod.user;
45 group = config.services.httpd.Prod.group;
46 permissions = "0400";
47 text = ''
48 # This file is auto-generated during the composer install
49 parameters:
50 database_host: ${secrets.mysql.host}
51 database_port: ${secrets.mysql.port}
52 database_name: ${secrets.mysql.name}
53 database_user: ${secrets.mysql.user}
54 database_password: ${secrets.mysql.password}
55 database_server_version: ${pkgs.mariadb.mysqlVersion}
56 mailer_transport: smtp
57 mailer_host: 127.0.0.1
58 mailer_user: null
59 mailer_password: null
60 secret: ${secrets.secret}
61 ldap_host: ldap.immae.eu
62 ldap_port: 636
63 ldap_version: 3
64 ldap_ssl: true
65 ldap_tls: false
66 ldap_user_bind: 'uid={username},ou=users,dc=immae,dc=eu'
67 ldap_base_dn: 'dc=immae,dc=eu'
68 ldap_search_dn: '${secrets.ldap.dn}'
69 ldap_search_password: '${secrets.ldap.password}'
70 ldap_search_filter: '${secrets.ldap.search}'
71 leapt_im:
72 binary_path: ${pkgs.imagemagick}/bin
73 assetic:
74 sass: ${pkgs.sass}/bin/sass
75 ruby: ${pkgs.ruby}/bin/ruby
76 '';
77 }
78 ];
17 79
18 systemd.services.phpfpm-ludivinecassal_prod.after = lib.mkAfter ludivinecassal.phpFpm.serviceDeps; 80 services.websites.env.production.vhostConfs.ludivinecassal_prod = {
19 systemd.services.phpfpm-ludivinecassal_prod.wants = ludivinecassal.phpFpm.serviceDeps;
20 systemd.services.phpfpm-ludivinecassal_prod.preStart = lib.mkAfter ludivinecassal.phpFpm.preStart;
21 services.phpfpm.poolConfigs.ludivinecassal_prod = ludivinecassal.phpFpm.pool;
22 system.activationScripts.ludivinecassal_prod = ludivinecassal.activationScript;
23 myServices.websites.webappDirs."${ludivinecassal.apache.webappName}" = ludivinecassal.app.webRoot;
24 services.websites.env.production.modules = ludivinecassal.apache.modules;
25 services.websites.env.production.vhostConfs.ludivine = {
26 certName = "ludivinecassal"; 81 certName = "ludivinecassal";
27 certMainHost = "ludivinecassal.com"; 82 certMainHost = "ludivinecassal.com";
28 hosts = ["ludivinecassal.com" "www.ludivinecassal.com" ]; 83 hosts = ["ludivinecassal.com" "www.ludivinecassal.com" ];
29 root = ludivinecassal.apache.root; 84 root = pcfg.webappDirs.ludivinecassal_prod;
30 extraConfig = [ ludivinecassal.apache.vhostConf ]; 85 extraConfig = [
31 }; 86 ''
32 services.filesWatcher.phpfpm-ludivinecassal_prod = { 87 <FilesMatch "\.php$">
33 restart = true; 88 SetHandler "proxy:unix:${pcfg.phpListenPaths.ludivinecassal_prod}|fcgi://localhost"
34 paths = [ "/var/secrets/webapps/${ludivinecassal.app.environment}-ludivinecassal" ]; 89 </FilesMatch>
90
91 Use Stats ludivinecassal.com
92
93 <Directory ${pcfg.webappDirs.ludivinecassal_prod}>
94 Options Indexes FollowSymLinks MultiViews Includes
95 AllowOverride All
96 Require all granted
97 </Directory>
98 ''
99 ];
35 }; 100 };
36 }; 101 };
37} 102}