aboutsummaryrefslogtreecommitdiff
path: root/virtual/modules/websites/connexionswing
diff options
context:
space:
mode:
authorIsmaël Bouya <ismael.bouya@normalesup.org>2019-01-10 23:02:54 +0100
committerIsmaël Bouya <ismael.bouya@normalesup.org>2019-01-10 23:20:03 +0100
commit091ae73429b8853e6ab971bffaccd84bdd59f40d (patch)
tree17ba770ff2e30c6f2b3f2e87dc8937093bd39e30 /virtual/modules/websites/connexionswing
parentad915416a6886010139413f4fbc41ed827336aa2 (diff)
downloadNix-091ae73429b8853e6ab971bffaccd84bdd59f40d.tar.gz
Nix-091ae73429b8853e6ab971bffaccd84bdd59f40d.tar.zst
Nix-091ae73429b8853e6ab971bffaccd84bdd59f40d.zip
Move packages fils to module
Diffstat (limited to 'virtual/modules/websites/connexionswing')
-rw-r--r--virtual/modules/websites/connexionswing/connexionswing.json14
-rw-r--r--virtual/modules/websites/connexionswing/connexionswing.nix181
-rw-r--r--virtual/modules/websites/connexionswing/default.nix66
-rw-r--r--virtual/modules/websites/connexionswing/goaccess.conf99
4 files changed, 360 insertions, 0 deletions
diff --git a/virtual/modules/websites/connexionswing/connexionswing.json b/virtual/modules/websites/connexionswing/connexionswing.json
new file mode 100644
index 0000000..146c5f6
--- /dev/null
+++ b/virtual/modules/websites/connexionswing/connexionswing.json
@@ -0,0 +1,14 @@
1{
2 "tag": "0330478-master",
3 "meta": {
4 "name": "connexionswing",
5 "url": "gitolite@git.immae.eu:perso/Immae/Projets/Connexionswing",
6 "branch": "master"
7 },
8 "git": {
9 "url": "gitolite@git.immae.eu:perso/Immae/Projets/Connexionswing",
10 "rev": "0330478cd256e6e36f525d3d0a247bad06de319f",
11 "sha256": "1sh97965winvbmpzqhjidhqry9840fa701wvr4vxywccyg4dyr17",
12 "fetchSubmodules": true
13 }
14}
diff --git a/virtual/modules/websites/connexionswing/connexionswing.nix b/virtual/modules/websites/connexionswing/connexionswing.nix
new file mode 100644
index 0000000..90cca73
--- /dev/null
+++ b/virtual/modules/websites/connexionswing/connexionswing.nix
@@ -0,0 +1,181 @@
1{ lib, checkEnv, writeText, fetchedGitPrivate, stdenv, php, git, cacert }:
2let
3 connexionswing = { environment ? "dev" }: rec {
4 varDir = "/var/lib/connexionswing_${environment}";
5 envName= lib.strings.toUpper environment;
6 configRoot =
7 # FIXME: spool emails in prod for when immae.eu is down?
8 assert checkEnv "NIXOPS_CONNEXIONSWING_${envName}_MYSQL_PASSWORD";
9 assert checkEnv "NIXOPS_CONNEXIONSWING_${envName}_MYSQL_USER";
10 assert checkEnv "NIXOPS_CONNEXIONSWING_${envName}_MYSQL_NAME";
11 assert checkEnv "NIXOPS_CONNEXIONSWING_${envName}_SECRET";
12 assert checkEnv "NIXOPS_CONNEXIONSWING_${envName}_EMAIL";
13 writeText "parameters.yml" ''
14 # This file is auto-generated during the composer install
15 parameters:
16 database_host: db-1.immae.eu
17 database_port: null
18 database_name: ${builtins.getEnv "NIXOPS_CONNEXIONSWING_${envName}_MYSQL_NAME"}
19 database_user: ${builtins.getEnv "NIXOPS_CONNEXIONSWING_${envName}_MYSQL_USER"}
20 database_password: ${builtins.getEnv "NIXOPS_CONNEXIONSWING_${envName}_MYSQL_PASSWORD"}
21 mailer_transport: smtp
22 mailer_host: mail.immae.eu
23 mailer_user: null
24 mailer_password: null
25 subscription_email: ${builtins.getEnv "NIXOPS_CONNEXIONSWING_${envName}_EMAIL"}
26 allow_robots: true
27 secret: ${builtins.getEnv "NIXOPS_CONNEXIONSWING_${envName}_SECRET"}
28 '';
29 phpFpm = rec {
30 socket = "/var/run/phpfpm/connexionswing-${environment}.sock";
31 pool = ''
32 listen = ${socket}
33 user = ${apache.user}
34 group = ${apache.group}
35 listen.owner = ${apache.user}
36 listen.group = ${apache.group}
37 php_admin_value[upload_max_filesize] = 20M
38 php_admin_value[post_max_size] = 20M
39 ;php_admin_flag[log_errors] = on
40 php_admin_value[open_basedir] = "${configRoot}:${webappDir}:${varDir}:/tmp"
41 php_admin_value[session.save_path] = "${varDir}/phpSessions"
42 ${if environment == "dev" then ''
43 pm = ondemand
44 pm.max_children = 5
45 pm.process_idle_timeout = 60
46 env[SYMFONY_DEBUG_MODE] = "yes"
47 '' else ''
48 pm = dynamic
49 pm.max_children = 20
50 pm.start_servers = 2
51 pm.min_spare_servers = 1
52 pm.max_spare_servers = 3
53 ''}'';
54 };
55 apache = {
56 user = "wwwrun";
57 group = "wwwrun";
58 modules = [ "proxy_fcgi" ];
59 vhostConf = ''
60 <FilesMatch "\.php$">
61 SetHandler "proxy:unix:${phpFpm.socket}|fcgi://localhost"
62 </FilesMatch>
63
64 <Directory ${varDir}/medias>
65 Options FollowSymLinks
66 AllowOverride None
67 Require all granted
68 </Directory>
69
70 <Directory ${varDir}/uploads>
71 Options FollowSymLinks
72 AllowOverride None
73 Require all granted
74 </Directory>
75
76 ${if environment == "dev" then ''
77 <Location />
78 Use LDAPConnect
79 Require ldap-group cn=connexionswing.immae.eu,cn=httpd,ou=services,dc=immae,dc=eu
80 ErrorDocument 401 "<html><meta http-equiv=\"refresh\" content=\"0;url=https://connexionswing.com\"></html>"
81 </Location>
82
83 <Directory ${webRoot}>
84 Options Indexes FollowSymLinks MultiViews Includes
85 AllowOverride None
86 Require all granted
87
88 DirectoryIndex app_dev.php
89
90 <IfModule mod_negotiation.c>
91 Options -MultiViews
92 </IfModule>
93
94 <IfModule mod_rewrite.c>
95 RewriteEngine On
96
97 RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$
98 RewriteRule ^(.*) - [E=BASE:%1]
99
100 # Maintenance script
101 RewriteCond %{DOCUMENT_ROOT}/maintenance.php -f
102 RewriteCond %{SCRIPT_FILENAME} !maintenance.php
103 RewriteRule ^.*$ %{ENV:BASE}/maintenance.php [R=503,L]
104 ErrorDocument 503 /maintenance.php
105
106 # Sets the HTTP_AUTHORIZATION header removed by Apache
107 RewriteCond %{HTTP:Authorization} .
108 RewriteRule ^ - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
109
110 RewriteCond %{ENV:REDIRECT_STATUS} ^$
111 RewriteRule ^app_dev\.php(?:/(.*)|$) %{ENV:BASE}/$1 [R=301,L]
112
113 # If the requested filename exists, simply serve it.
114 # We only want to let Apache serve files and not directories.
115 RewriteCond %{REQUEST_FILENAME} -f
116 RewriteRule ^ - [L]
117
118 # Rewrite all other queries to the front controller.
119 RewriteRule ^ %{ENV:BASE}/app_dev.php [L]
120 </IfModule>
121
122 </Directory>
123 '' else ''
124 Use Stats connexionswing.com
125
126 <Directory ${webRoot}>
127 Options Indexes FollowSymLinks MultiViews Includes
128 AllowOverride All
129 Require all granted
130 </Directory>
131 ''}
132 '';
133 };
134 activationScript = {
135 deps = [ "wrappers" ];
136 text = ''
137 install -m 0755 -o ${apache.user} -g ${apache.group} -d ${varDir} \
138 ${varDir}/medias \
139 ${varDir}/uploads \
140 ${varDir}/var
141 install -m 0750 -o ${apache.user} -g ${apache.group} -d ${varDir}/phpSessions
142 if [ ! -f "${varDir}/currentWebappDir" -o \
143 "${webappDir}" != "$(cat ${varDir}/currentWebappDir 2>/dev/null)" ]; then
144 pushd ${webappDir} > /dev/null
145 $wrapperDir/sudo -u wwwrun ./bin/console --env=${environment} cache:clear --no-warmup
146 popd > /dev/null
147 echo -n "${webappDir}" > ${varDir}/currentWebappDir
148 fi
149 '';
150 };
151 webappDir = stdenv.mkDerivation (fetchedGitPrivate ./connexionswing.json // rec {
152 # FIXME: can we do better than symlink?
153 # FIXME: imagick optional
154 # FIXME: initial sync
155 # FIXME: backup
156 # FIXME: replace with pkgs.phpPackages.composer
157 buildPhase = ''
158 export GIT_SSL_CAINFO=${cacert}/etc/ssl/certs/ca-bundle.crt
159 export SSL_CERT_FILE=${cacert}/etc/ssl/certs/ca-bundle.crt
160
161 ln -sf ../../../../../${varDir}/{medias,uploads} web/images/
162 ln -sf ${configRoot} app/config/parameters.yml
163 sed -i -e "/Incenteev..ParameterHandler..ScriptHandler::buildParameters/d" composer.json
164 ${if environment == "dev" then "php bin/composer install" else ''
165 SYMFONY_ENV=prod php bin/composer install --no-dev
166 ./bin/console assetic:dump --env=prod --no-debug
167 ''}
168 rm -rf var
169 ln -sf ../../../../../${varDir}/var var
170 '';
171 installPhase = ''
172 cp -a . $out
173 '';
174 buildInputs = [
175 php git cacert
176 ];
177 });
178 webRoot = "${webappDir}/web";
179 };
180in
181 connexionswing
diff --git a/virtual/modules/websites/connexionswing/default.nix b/virtual/modules/websites/connexionswing/default.nix
new file mode 100644
index 0000000..636b16e
--- /dev/null
+++ b/virtual/modules/websites/connexionswing/default.nix
@@ -0,0 +1,66 @@
1{ lib, pkgs, config, mylibs, ... }:
2let
3 connexionswing = pkgs.callPackage ./connexionswing.nix { inherit (mylibs) checkEnv fetchedGitPrivate; };
4 connexionswing_dev = connexionswing { environment = "dev"; };
5 connexionswing_prod = connexionswing { environment = "prod"; };
6
7 cfg = config.services.myWebsites.Connexionswing;
8in {
9 options.services.myWebsites.Connexionswing = {
10 production = {
11 enable = lib.mkEnableOption "enable Connexionswing's website in production";
12 };
13 integration = {
14 enable = lib.mkEnableOption "enable Connexionswing's website in integration";
15 };
16 };
17
18 imports = [
19 ../commons/stats.nix
20 ];
21
22 config = lib.mkMerge [
23 (lib.mkIf cfg.production.enable {
24 services.myWebsites.commons.stats.enable = true;
25 services.myWebsites.commons.stats.sites = [
26 {
27 name = "connexionswing.com";
28 conf = ./goaccess.conf;
29 }
30 ];
31
32 security.acme.certs."connexionswing" = config.services.myCertificates.certConfig // {
33 domain = "connexionswing.com";
34 extraDomains = {
35 "www.connexionswing.com" = null;
36 "sandetludo.com" = null;
37 "www.sandetludo.com" = null;
38 };
39 };
40
41 services.phpfpm.poolConfigs.connexionswing_prod = connexionswing_prod.phpFpm.pool;
42 system.activationScripts.connexionswing_prod = connexionswing_prod.activationScript;
43 services.myWebsites.production.modules = connexionswing_prod.apache.modules;
44 services.myWebsites.production.vhostConfs.connexionswing = {
45 certName = "connexionswing";
46 hosts = ["connexionswing.com" "sandetludo.com" "www.connexionswing.com" "www.sandetludo.com" ];
47 root = connexionswing_prod.webRoot;
48 extraConfig = [ connexionswing_prod.apache.vhostConf ];
49 };
50 })
51 (lib.mkIf cfg.integration.enable {
52 security.acme.certs."eldiron".extraDomains."sandetludo.immae.eu" = null;
53 security.acme.certs."eldiron".extraDomains."connexionswing.immae.eu" = null;
54 services.phpfpm.poolConfigs.connexionswing_dev = connexionswing_dev.phpFpm.pool;
55 system.activationScripts.connexionswing_dev = connexionswing_dev.activationScript;
56 services.myWebsites.integration.modules = connexionswing_dev.apache.modules;
57 services.myWebsites.integration.vhostConfs.connexionswing = {
58 certName = "eldiron";
59 hosts = ["connexionswing.immae.eu" "sandetludo.immae.eu" ];
60 root = connexionswing_dev.webRoot;
61 extraConfig = [ connexionswing_dev.apache.vhostConf ];
62 };
63 })
64 ];
65}
66
diff --git a/virtual/modules/websites/connexionswing/goaccess.conf b/virtual/modules/websites/connexionswing/goaccess.conf
new file mode 100644
index 0000000..05ad083
--- /dev/null
+++ b/virtual/modules/websites/connexionswing/goaccess.conf
@@ -0,0 +1,99 @@
1time-format %H:%M:%S
2date-format %d/%b/%Y
3
4#sur immae.eu
5#log-format %v %h %^[%d:%t %^] "%r" %s %b "%R" "%u" $^
6
7log-format VCOMBINED
8#= %v:%^ %h %^[%d:%t %^] "%r" %s %b "%R" "%u"
9
10html-prefs {"theme":"bright","layout":"vertical"}
11
12exclude-ip 188.165.209.148
13exclude-ip 178.33.252.96
14exclude-ip 2001:41d0:2:9c94::1
15exclude-ip 2001:41d0:2:9c94::
16exclude-ip 176.9.151.89
17exclude-ip 2a01:4f8:160:3445::
18exclude-ip 82.255.56.72
19
20no-query-string true
21
22keep-db-files true
23load-from-disk true
24db-path /var/lib/goaccess/connexionswing.com
25
26ignore-panel REFERRERS
27ignore-panel KEYPHRASES
28
29static-file .css
30static-file .js
31static-file .jpg
32static-file .png
33static-file .gif
34static-file .ico
35static-file .jpeg
36static-file .pdf
37static-file .csv
38static-file .mpeg
39static-file .mpg
40static-file .swf
41static-file .woff
42static-file .woff2
43static-file .xls
44static-file .xlsx
45static-file .doc
46static-file .docx
47static-file .ppt
48static-file .pptx
49static-file .txt
50static-file .zip
51static-file .ogg
52static-file .mp3
53static-file .mp4
54static-file .exe
55static-file .iso
56static-file .gz
57static-file .rar
58static-file .svg
59static-file .bmp
60static-file .tar
61static-file .tgz
62static-file .tiff
63static-file .tif
64static-file .ttf
65static-file .flv
66#static-file .less
67#static-file .ac3
68#static-file .avi
69#static-file .bz2
70#static-file .class
71#static-file .cue
72#static-file .dae
73#static-file .dat
74#static-file .dts
75#static-file .ejs
76#static-file .eot
77#static-file .eps
78#static-file .img
79#static-file .jar
80#static-file .map
81#static-file .mid
82#static-file .midi
83#static-file .ogv
84#static-file .webm
85#static-file .mkv
86#static-file .odp
87#static-file .ods
88#static-file .odt
89#static-file .otf
90#static-file .pict
91#static-file .pls
92#static-file .ps
93#static-file .qt
94#static-file .rm
95#static-file .svgz
96#static-file .wav
97#static-file .webp
98
99