aboutsummaryrefslogtreecommitdiff
path: root/virtual/modules/websites/piedsjaloux
diff options
context:
space:
mode:
Diffstat (limited to 'virtual/modules/websites/piedsjaloux')
-rw-r--r--virtual/modules/websites/piedsjaloux/default.nix63
-rw-r--r--virtual/modules/websites/piedsjaloux/goaccess.conf99
-rw-r--r--virtual/modules/websites/piedsjaloux/piedsjaloux.json14
-rw-r--r--virtual/modules/websites/piedsjaloux/piedsjaloux.nix171
4 files changed, 347 insertions, 0 deletions
diff --git a/virtual/modules/websites/piedsjaloux/default.nix b/virtual/modules/websites/piedsjaloux/default.nix
new file mode 100644
index 0000000..bf74173
--- /dev/null
+++ b/virtual/modules/websites/piedsjaloux/default.nix
@@ -0,0 +1,63 @@
1{ lib, pkgs, config, mylibs, ... }:
2let
3 piedsjaloux = pkgs.callPackage ./piedsjaloux.nix { inherit (mylibs) checkEnv fetchedGitPrivate; };
4 piedsjaloux_dev = piedsjaloux { environment = "dev"; };
5 piedsjaloux_prod = piedsjaloux { environment = "prod"; };
6
7 cfg = config.services.myWebsites.PiedsJaloux;
8in {
9 options.services.myWebsites.PiedsJaloux = {
10 production = {
11 enable = lib.mkEnableOption "enable PiedsJaloux's website in production";
12 };
13 integration = {
14 enable = lib.mkEnableOption "enable PiedsJaloux'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 = "piedsjaloux.fr";
28 conf = ./goaccess.conf;
29 }
30 ];
31
32 security.acme.certs."piedsjaloux" = config.services.myCertificates.certConfig // {
33 domain = "piedsjaloux.fr";
34 extraDomains = {
35 "www.piedsjaloux.fr" = null;
36 };
37 };
38
39 services.phpfpm.poolConfigs.piedsjaloux_prod = piedsjaloux_prod.phpFpm.pool;
40 system.activationScripts.piedsjaloux_prod = piedsjaloux_prod.activationScript;
41 services.myWebsites.production.modules = piedsjaloux_prod.apache.modules;
42 services.myWebsites.production.vhostConfs.piedsjaloux = {
43 certName = "piedsjaloux";
44 hosts = [ "piedsjaloux.fr" "www.piedsjaloux.fr" ];
45 root = piedsjaloux_prod.webRoot;
46 extraConfig = [ piedsjaloux_prod.apache.vhostConf ];
47 };
48 })
49 (lib.mkIf cfg.integration.enable {
50 security.acme.certs."eldiron".extraDomains."piedsjaloux.immae.eu" = null;
51 services.phpfpm.poolConfigs.piedsjaloux_dev = piedsjaloux_dev.phpFpm.pool;
52 system.activationScripts.piedsjaloux_dev = piedsjaloux_dev.activationScript;
53 services.myWebsites.integration.modules = piedsjaloux_dev.apache.modules;
54 services.myWebsites.integration.vhostConfs.piedsjaloux = {
55 certName = "eldiron";
56 hosts = [ "piedsjaloux.immae.eu" ];
57 root = piedsjaloux_dev.webRoot;
58 extraConfig = [ piedsjaloux_dev.apache.vhostConf ];
59 };
60 })
61 ];
62}
63
diff --git a/virtual/modules/websites/piedsjaloux/goaccess.conf b/virtual/modules/websites/piedsjaloux/goaccess.conf
new file mode 100644
index 0000000..3950f7e
--- /dev/null
+++ b/virtual/modules/websites/piedsjaloux/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/piedsjaloux.fr
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
diff --git a/virtual/modules/websites/piedsjaloux/piedsjaloux.json b/virtual/modules/websites/piedsjaloux/piedsjaloux.json
new file mode 100644
index 0000000..c4aae16
--- /dev/null
+++ b/virtual/modules/websites/piedsjaloux/piedsjaloux.json
@@ -0,0 +1,14 @@
1{
2 "tag": "c7a5593-master",
3 "meta": {
4 "name": "piedsjaloux",
5 "url": "gitolite@git.immae.eu:Pieds_jaloux/NewSite",
6 "branch": "master"
7 },
8 "git": {
9 "url": "gitolite@git.immae.eu:Pieds_jaloux/NewSite",
10 "rev": "c7a5593c37040c6f1f57f8163bc13256aabf6b3e",
11 "sha256": "1zvyd90d6xns6ypnp1p3fgbcl30pqwdv335qagbbjak1cn8jaq4l",
12 "fetchSubmodules": true
13 }
14}
diff --git a/virtual/modules/websites/piedsjaloux/piedsjaloux.nix b/virtual/modules/websites/piedsjaloux/piedsjaloux.nix
new file mode 100644
index 0000000..1c3d8b7
--- /dev/null
+++ b/virtual/modules/websites/piedsjaloux/piedsjaloux.nix
@@ -0,0 +1,171 @@
1{ lib, checkEnv, writeText, fetchedGitPrivate, stdenv, php, git, cacert, phpPackages, texlive, imagemagick }:
2let
3 piedsjaloux = { environment ? "dev" }: rec {
4 varPrefix = "PIEDSJALOUX";
5 varDir = "/var/lib/piedsjaloux_${environment}";
6 envName= lib.strings.toUpper environment;
7 configRoot =
8 assert checkEnv "NIXOPS_${varPrefix}_${envName}_MYSQL_PASSWORD";
9 assert checkEnv "NIXOPS_${varPrefix}_${envName}_MYSQL_USER";
10 assert checkEnv "NIXOPS_${varPrefix}_${envName}_MYSQL_NAME";
11 assert checkEnv "NIXOPS_${varPrefix}_${envName}_SECRET";
12 writeText "parameters.yml" ''
13 # This file is auto-generated during the composer install
14 parameters:
15 database_host: db-1.immae.eu
16 database_port: null
17 database_name: ${builtins.getEnv "NIXOPS_${varPrefix}_${envName}_MYSQL_NAME"}
18 database_user: ${builtins.getEnv "NIXOPS_${varPrefix}_${envName}_MYSQL_USER"}
19 database_password: ${builtins.getEnv "NIXOPS_${varPrefix}_${envName}_MYSQL_PASSWORD"}
20 mailer_transport: smtp
21 mailer_host: mail.immae.eu
22 mailer_user: null
23 mailer_password: null
24 secret: ${builtins.getEnv "NIXOPS_${varPrefix}_${envName}_SECRET"}
25 pdflatex: "${texlive.combine { inherit (texlive) attachfile preprint scheme-small; }}/bin/pdflatex"
26 leapt_im:
27 binary_path: ${imagemagick}/bin
28 '';
29 phpFpm = rec {
30 socket = "/var/run/phpfpm/piedsjaloux-${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 ${if environment == "dev" then ''
65 <Location />
66 Use LDAPConnect
67 Require ldap-group cn=piedsjaloux.immae.eu,cn=httpd,ou=services,dc=immae,dc=eu
68 ErrorDocument 401 "<html><meta http-equiv=\"refresh\" content=\"0;url=https://piedsjaloux.fr\"></html>"
69 </Location>
70
71 <Directory ${webRoot}>
72 Options Indexes FollowSymLinks MultiViews Includes
73 AllowOverride None
74 Require all granted
75
76 DirectoryIndex app_dev.php
77
78 <IfModule mod_negotiation.c>
79 Options -MultiViews
80 </IfModule>
81
82 <IfModule mod_rewrite.c>
83 RewriteEngine On
84
85 RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$
86 RewriteRule ^(.*) - [E=BASE:%1]
87
88 # Maintenance script
89 RewriteCond %{DOCUMENT_ROOT}/maintenance.php -f
90 RewriteCond %{SCRIPT_FILENAME} !maintenance.php
91 RewriteRule ^.*$ %{ENV:BASE}/maintenance.php [R=503,L]
92 ErrorDocument 503 /maintenance.php
93
94 # Sets the HTTP_AUTHORIZATION header removed by Apache
95 RewriteCond %{HTTP:Authorization} .
96 RewriteRule ^ - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
97
98 RewriteCond %{ENV:REDIRECT_STATUS} ^$
99 RewriteRule ^app_dev\.php(?:/(.*)|$) %{ENV:BASE}/$1 [R=301,L]
100
101 # If the requested filename exists, simply serve it.
102 # We only want to let Apache serve files and not directories.
103 RewriteCond %{REQUEST_FILENAME} -f
104 RewriteRule ^ - [L]
105
106 # Rewrite all other queries to the front controller.
107 RewriteRule ^ %{ENV:BASE}/app_dev.php [L]
108 </IfModule>
109
110 </Directory>
111 '' else ''
112 Use Stats piedsjaloux.fr
113
114 <Directory ${webRoot}>
115 Options Indexes FollowSymLinks MultiViews Includes
116 AllowOverride All
117 Require all granted
118 </Directory>
119 ''}
120 '';
121 };
122 activationScript = {
123 deps = [ "wrappers" ];
124 text = ''
125 install -m 0755 -o ${apache.user} -g ${apache.group} -d ${varDir} \
126 ${varDir}/tmp
127 install -m 0750 -o ${apache.user} -g ${apache.group} -d ${varDir}/phpSessions
128 if [ ! -f "${varDir}/currentWebappDir" -o \
129 "${webappDir}" != "$(cat ${varDir}/currentWebappDir 2>/dev/null)" ]; then
130 pushd ${webappDir} > /dev/null
131 $wrapperDir/sudo -u wwwrun ./bin/console --env=${environment} cache:clear --no-warmup
132 popd > /dev/null
133 echo -n "${webappDir}" > ${varDir}/currentWebappDir
134 fi
135 '';
136 };
137 webappDir = stdenv.mkDerivation (fetchedGitPrivate ./piedsjaloux.json // rec {
138 # FIXME: can we do better than symlink?
139 # FIXME: initial sync
140 # FIXME: backup
141 # FIXME: miniatures and data need to be in the same dir due to a
142 # bug in leapt.im (searches for data/../miniatures)
143 # FIXME: var/bootstrap.php.cache doesn't get created
144 # (cannot work with var as a symlink since the file
145 # references ..)
146 # FIXME: configuration change should not trigger a rebuild
147 buildPhase = ''
148 export GIT_SSL_CAINFO=${cacert}/etc/ssl/certs/ca-bundle.crt
149 export SSL_CERT_FILE=${cacert}/etc/ssl/certs/ca-bundle.crt
150
151 ln -sf ${configRoot} app/config/parameters.yml
152 sed -i -e "/Incenteev..ParameterHandler..ScriptHandler::buildParameters/d" composer.json
153 ${if environment == "dev" then ''
154 composer install
155 '' else ''
156 SYMFONY_ENV=prod composer install --no-dev
157 ''}
158 rm -rf var
159 ln -sf ../../../../../${varDir} var
160 '';
161 installPhase = ''
162 cp -a . $out
163 '';
164 buildInputs = [
165 php git cacert phpPackages.composer
166 ];
167 });
168 webRoot = "${webappDir}/web";
169 };
170in
171 piedsjaloux