diff options
author | Ismaël Bouya <ismael.bouya@normalesup.org> | 2019-01-10 23:02:54 +0100 |
---|---|---|
committer | Ismaël Bouya <ismael.bouya@normalesup.org> | 2019-01-10 23:20:03 +0100 |
commit | 091ae73429b8853e6ab971bffaccd84bdd59f40d (patch) | |
tree | 17ba770ff2e30c6f2b3f2e87dc8937093bd39e30 /virtual/modules/websites/ludivine | |
parent | ad915416a6886010139413f4fbc41ed827336aa2 (diff) | |
download | Nix-091ae73429b8853e6ab971bffaccd84bdd59f40d.tar.gz Nix-091ae73429b8853e6ab971bffaccd84bdd59f40d.tar.zst Nix-091ae73429b8853e6ab971bffaccd84bdd59f40d.zip |
Move packages fils to module
Diffstat (limited to 'virtual/modules/websites/ludivine')
-rw-r--r-- | virtual/modules/websites/ludivine/default.nix | 60 | ||||
-rw-r--r-- | virtual/modules/websites/ludivine/goaccess.conf | 99 | ||||
-rw-r--r-- | virtual/modules/websites/ludivine/ludivinecassal.json | 14 | ||||
-rw-r--r-- | virtual/modules/websites/ludivine/ludivinecassal.nix | 181 |
4 files changed, 354 insertions, 0 deletions
diff --git a/virtual/modules/websites/ludivine/default.nix b/virtual/modules/websites/ludivine/default.nix new file mode 100644 index 0000000..ed719ba --- /dev/null +++ b/virtual/modules/websites/ludivine/default.nix | |||
@@ -0,0 +1,60 @@ | |||
1 | { lib, pkgs, config, mylibs, ... }: | ||
2 | let | ||
3 | ludivinecassal = pkgs.callPackage ./ludivinecassal.nix { inherit (mylibs) checkEnv fetchedGitPrivate; }; | ||
4 | ludivinecassal_dev = ludivinecassal { environment = "dev"; }; | ||
5 | ludivinecassal_prod = ludivinecassal { environment = "prod"; }; | ||
6 | |||
7 | cfg = config.services.myWebsites.Ludivine; | ||
8 | in { | ||
9 | options.services.myWebsites.Ludivine = { | ||
10 | production = { | ||
11 | enable = lib.mkEnableOption "enable Ludivine's website in production"; | ||
12 | }; | ||
13 | integration = { | ||
14 | enable = lib.mkEnableOption "enable Ludivine's website in integration"; | ||
15 | }; | ||
16 | }; | ||
17 | |||
18 | config = lib.mkMerge [ | ||
19 | (lib.mkIf cfg.production.enable { | ||
20 | services.myWebsites.commons.stats.enable = true; | ||
21 | services.myWebsites.commons.stats.sites = [ | ||
22 | { | ||
23 | name = "ludivinecassal.com"; | ||
24 | conf = ./goaccess.conf; | ||
25 | } | ||
26 | ]; | ||
27 | |||
28 | security.acme.certs."ludivinecassal" = config.services.myCertificates.certConfig // { | ||
29 | domain = "ludivinecassal.com"; | ||
30 | extraDomains = { | ||
31 | "www.ludivinecassal.com" = null; | ||
32 | }; | ||
33 | }; | ||
34 | |||
35 | services.phpfpm.poolConfigs.ludivinecassal_prod = ludivinecassal_prod.phpFpm.pool; | ||
36 | system.activationScripts.ludivinecassal_prod = ludivinecassal_prod.activationScript; | ||
37 | services.myWebsites.production.modules = ludivinecassal_prod.apache.modules; | ||
38 | services.myWebsites.production.vhostConfs.ludivine = { | ||
39 | certName = "ludivinecassal"; | ||
40 | hosts = ["ludivinecassal.com" "www.ludivinecassal.com" ]; | ||
41 | root = ludivinecassal_prod.webRoot; | ||
42 | extraConfig = [ ludivinecassal_prod.apache.vhostConf ]; | ||
43 | }; | ||
44 | }) | ||
45 | (lib.mkIf cfg.integration.enable { | ||
46 | security.acme.certs."eldiron".extraDomains."ludivine.immae.eu" = null; | ||
47 | |||
48 | services.phpfpm.poolConfigs.ludivinecassal_dev = ludivinecassal_dev.phpFpm.pool; | ||
49 | system.activationScripts.ludivinecassal_dev = ludivinecassal_dev.activationScript; | ||
50 | services.myWebsites.apacheConfig.ludivinecassal_dev.modules = ludivinecassal_dev.apache.modules; | ||
51 | services.myWebsites.integration.modules = ludivinecassal_dev.apache.modules; | ||
52 | services.myWebsites.integration.vhostConfs.ludivine = { | ||
53 | certName = "eldiron"; | ||
54 | hosts = [ "ludivine.immae.eu" ]; | ||
55 | root = ludivinecassal_dev.webRoot; | ||
56 | extraConfig = [ ludivinecassal_dev.apache.vhostConf ]; | ||
57 | }; | ||
58 | }) | ||
59 | ]; | ||
60 | } | ||
diff --git a/virtual/modules/websites/ludivine/goaccess.conf b/virtual/modules/websites/ludivine/goaccess.conf new file mode 100644 index 0000000..25e5f63 --- /dev/null +++ b/virtual/modules/websites/ludivine/goaccess.conf | |||
@@ -0,0 +1,99 @@ | |||
1 | time-format %H:%M:%S | ||
2 | date-format %d/%b/%Y | ||
3 | |||
4 | #sur immae.eu | ||
5 | #log-format %v %h %^[%d:%t %^] "%r" %s %b "%R" "%u" $^ | ||
6 | |||
7 | log-format VCOMBINED | ||
8 | #= %v:%^ %h %^[%d:%t %^] "%r" %s %b "%R" "%u" | ||
9 | |||
10 | html-prefs {"theme":"bright","layout":"vertical"} | ||
11 | |||
12 | exclude-ip 188.165.209.148 | ||
13 | exclude-ip 178.33.252.96 | ||
14 | exclude-ip 2001:41d0:2:9c94::1 | ||
15 | exclude-ip 2001:41d0:2:9c94:: | ||
16 | exclude-ip 176.9.151.89 | ||
17 | exclude-ip 2a01:4f8:160:3445:: | ||
18 | exclude-ip 82.255.56.72 | ||
19 | |||
20 | no-query-string true | ||
21 | |||
22 | keep-db-files true | ||
23 | load-from-disk true | ||
24 | db-path /var/lib/goaccess/ludivinecassal.com | ||
25 | |||
26 | ignore-panel REFERRERS | ||
27 | ignore-panel KEYPHRASES | ||
28 | |||
29 | static-file .css | ||
30 | static-file .js | ||
31 | static-file .jpg | ||
32 | static-file .png | ||
33 | static-file .gif | ||
34 | static-file .ico | ||
35 | static-file .jpeg | ||
36 | static-file .pdf | ||
37 | static-file .csv | ||
38 | static-file .mpeg | ||
39 | static-file .mpg | ||
40 | static-file .swf | ||
41 | static-file .woff | ||
42 | static-file .woff2 | ||
43 | static-file .xls | ||
44 | static-file .xlsx | ||
45 | static-file .doc | ||
46 | static-file .docx | ||
47 | static-file .ppt | ||
48 | static-file .pptx | ||
49 | static-file .txt | ||
50 | static-file .zip | ||
51 | static-file .ogg | ||
52 | static-file .mp3 | ||
53 | static-file .mp4 | ||
54 | static-file .exe | ||
55 | static-file .iso | ||
56 | static-file .gz | ||
57 | static-file .rar | ||
58 | static-file .svg | ||
59 | static-file .bmp | ||
60 | static-file .tar | ||
61 | static-file .tgz | ||
62 | static-file .tiff | ||
63 | static-file .tif | ||
64 | static-file .ttf | ||
65 | static-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/ludivine/ludivinecassal.json b/virtual/modules/websites/ludivine/ludivinecassal.json new file mode 100644 index 0000000..89667c0 --- /dev/null +++ b/virtual/modules/websites/ludivine/ludivinecassal.json | |||
@@ -0,0 +1,14 @@ | |||
1 | { | ||
2 | "tag": "4327b82-master", | ||
3 | "meta": { | ||
4 | "name": "ludivinecassal", | ||
5 | "url": "gitolite@git.immae.eu:perso/Immae/Sites/Ludivine", | ||
6 | "branch": "master" | ||
7 | }, | ||
8 | "git": { | ||
9 | "url": "gitolite@git.immae.eu:perso/Immae/Sites/Ludivine", | ||
10 | "rev": "4327b82ec00cc514bfce5aa7155bcdbcc871c065", | ||
11 | "sha256": "1c5hnzvyvj45j61v2v5mh1l405ih74f58isr9dq21428kcfc2gyd", | ||
12 | "fetchSubmodules": true | ||
13 | } | ||
14 | } | ||
diff --git a/virtual/modules/websites/ludivine/ludivinecassal.nix b/virtual/modules/websites/ludivine/ludivinecassal.nix new file mode 100644 index 0000000..ac63735 --- /dev/null +++ b/virtual/modules/websites/ludivine/ludivinecassal.nix | |||
@@ -0,0 +1,181 @@ | |||
1 | { lib, checkEnv, writeText, fetchedGitPrivate, stdenv, php, git, cacert, phpPackages, ruby, sass, imagemagick }: | ||
2 | let | ||
3 | ludivinecassal = { environment ? "dev" }: rec { | ||
4 | varPrefix = "LUDIVINECASSAL"; | ||
5 | varDir = "/var/lib/ludivinecassal_${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 | assert checkEnv "NIXOPS_${varPrefix}_${envName}_LDAP_PASSWORD"; | ||
13 | assert checkEnv "NIXOPS_${varPrefix}_${envName}_LDAP_SEARCH_DN"; | ||
14 | assert checkEnv "NIXOPS_${varPrefix}_${envName}_LDAP_SEARCH_FILTER"; | ||
15 | writeText "parameters.yml" '' | ||
16 | # This file is auto-generated during the composer install | ||
17 | parameters: | ||
18 | database_host: db-1.immae.eu | ||
19 | database_port: null | ||
20 | database_name: ${builtins.getEnv "NIXOPS_${varPrefix}_${envName}_MYSQL_NAME"} | ||
21 | database_user: ${builtins.getEnv "NIXOPS_${varPrefix}_${envName}_MYSQL_USER"} | ||
22 | database_password: ${builtins.getEnv "NIXOPS_${varPrefix}_${envName}_MYSQL_PASSWORD"} | ||
23 | mailer_transport: smtp | ||
24 | mailer_host: mail.immae.eu | ||
25 | mailer_user: null | ||
26 | mailer_password: null | ||
27 | secret: ${builtins.getEnv "NIXOPS_${varPrefix}_${envName}_SECRET"} | ||
28 | ldap_host: ldap.immae.eu | ||
29 | ldap_port: 636 | ||
30 | ldap_version: 3 | ||
31 | ldap_ssl: true | ||
32 | ldap_tls: false | ||
33 | ldap_user_bind: 'uid={username},ou=users,dc=immae,dc=eu' | ||
34 | ldap_base_dn: 'dc=immae,dc=eu' | ||
35 | ldap_search_dn: '${builtins.getEnv "NIXOPS_${varPrefix}_${envName}_LDAP_SEARCH_DN"}' | ||
36 | ldap_search_password: '${builtins.getEnv "NIXOPS_${varPrefix}_${envName}_LDAP_PASSWORD"}' | ||
37 | ldap_search_filter: '${builtins.getEnv "NIXOPS_${varPrefix}_${envName}_LDAP_SEARCH_FILTER"}' | ||
38 | leapt_im: | ||
39 | binary_path: ${imagemagick}/bin | ||
40 | assetic: | ||
41 | sass: ${sass}/bin/sass | ||
42 | ruby: ${ruby}/bin/ruby | ||
43 | ''; | ||
44 | phpFpm = rec { | ||
45 | socket = "/var/run/phpfpm/ludivinecassal-${environment}.sock"; | ||
46 | pool = '' | ||
47 | listen = ${socket} | ||
48 | user = ${apache.user} | ||
49 | group = ${apache.group} | ||
50 | listen.owner = ${apache.user} | ||
51 | listen.group = ${apache.group} | ||
52 | php_admin_value[upload_max_filesize] = 20M | ||
53 | php_admin_value[post_max_size] = 20M | ||
54 | ;php_admin_flag[log_errors] = on | ||
55 | php_admin_value[open_basedir] = "${configRoot}:${webappDir}:${varDir}:/tmp" | ||
56 | php_admin_value[session.save_path] = "${varDir}/phpSessions" | ||
57 | ${if environment == "dev" then '' | ||
58 | pm = ondemand | ||
59 | pm.max_children = 5 | ||
60 | pm.process_idle_timeout = 60 | ||
61 | env[SYMFONY_DEBUG_MODE] = "yes" | ||
62 | '' else '' | ||
63 | pm = dynamic | ||
64 | pm.max_children = 20 | ||
65 | pm.start_servers = 2 | ||
66 | pm.min_spare_servers = 1 | ||
67 | pm.max_spare_servers = 3 | ||
68 | ''}''; | ||
69 | }; | ||
70 | apache = { | ||
71 | user = "wwwrun"; | ||
72 | group = "wwwrun"; | ||
73 | modules = [ "proxy_fcgi" ]; | ||
74 | vhostConf = '' | ||
75 | <FilesMatch "\.php$"> | ||
76 | SetHandler "proxy:unix:${phpFpm.socket}|fcgi://localhost" | ||
77 | </FilesMatch> | ||
78 | |||
79 | ${if environment == "dev" then '' | ||
80 | <Location /> | ||
81 | Use LDAPConnect | ||
82 | Require ldap-group cn=ludivine.immae.eu,cn=httpd,ou=services,dc=immae,dc=eu | ||
83 | ErrorDocument 401 "<html><meta http-equiv=\"refresh\" content=\"0;url=https://ludivinecassal.com\"></html>" | ||
84 | </Location> | ||
85 | |||
86 | <Directory ${webRoot}> | ||
87 | Options Indexes FollowSymLinks MultiViews Includes | ||
88 | AllowOverride None | ||
89 | Require all granted | ||
90 | |||
91 | DirectoryIndex app_dev.php | ||
92 | |||
93 | <IfModule mod_negotiation.c> | ||
94 | Options -MultiViews | ||
95 | </IfModule> | ||
96 | |||
97 | <IfModule mod_rewrite.c> | ||
98 | RewriteEngine On | ||
99 | |||
100 | RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$ | ||
101 | RewriteRule ^(.*) - [E=BASE:%1] | ||
102 | |||
103 | # Maintenance script | ||
104 | RewriteCond %{DOCUMENT_ROOT}/maintenance.php -f | ||
105 | RewriteCond %{SCRIPT_FILENAME} !maintenance.php | ||
106 | RewriteRule ^.*$ %{ENV:BASE}/maintenance.php [R=503,L] | ||
107 | ErrorDocument 503 /maintenance.php | ||
108 | |||
109 | # Sets the HTTP_AUTHORIZATION header removed by Apache | ||
110 | RewriteCond %{HTTP:Authorization} . | ||
111 | RewriteRule ^ - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] | ||
112 | |||
113 | RewriteCond %{ENV:REDIRECT_STATUS} ^$ | ||
114 | RewriteRule ^app_dev\.php(?:/(.*)|$) %{ENV:BASE}/$1 [R=301,L] | ||
115 | |||
116 | # If the requested filename exists, simply serve it. | ||
117 | # We only want to let Apache serve files and not directories. | ||
118 | RewriteCond %{REQUEST_FILENAME} -f | ||
119 | RewriteRule ^ - [L] | ||
120 | |||
121 | # Rewrite all other queries to the front controller. | ||
122 | RewriteRule ^ %{ENV:BASE}/app_dev.php [L] | ||
123 | </IfModule> | ||
124 | |||
125 | </Directory> | ||
126 | '' else '' | ||
127 | Use Stats ludivinecassal.com | ||
128 | |||
129 | <Directory ${webRoot}> | ||
130 | Options Indexes FollowSymLinks MultiViews Includes | ||
131 | AllowOverride All | ||
132 | Require all granted | ||
133 | </Directory> | ||
134 | ''} | ||
135 | ''; | ||
136 | }; | ||
137 | activationScript = { | ||
138 | deps = [ "wrappers" ]; | ||
139 | text = '' | ||
140 | install -m 0755 -o ${apache.user} -g ${apache.group} -d ${varDir} | ||
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 ./ludivinecassal.json // rec { | ||
152 | # FIXME: can we do better than symlink? | ||
153 | # FIXME: initial sync | ||
154 | # FIXME: backup | ||
155 | # FIXME: miniatures and data need to be in the same dir due to a | ||
156 | # bug in leapt.im (searches for data/../miniatures) | ||
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 ${configRoot} app/config/parameters.yml | ||
162 | sed -i -e "/Incenteev..ParameterHandler..ScriptHandler::buildParameters/d" composer.json | ||
163 | ${if environment == "dev" then '' | ||
164 | composer install | ||
165 | '' else '' | ||
166 | SYMFONY_ENV=prod composer install --no-dev | ||
167 | ''} | ||
168 | rm -rf var | ||
169 | ln -sf ../../../../../${varDir} var | ||
170 | ''; | ||
171 | installPhase = '' | ||
172 | cp -a . $out | ||
173 | ''; | ||
174 | buildInputs = [ | ||
175 | php git cacert phpPackages.composer sass | ||
176 | ]; | ||
177 | }); | ||
178 | webRoot = "${webappDir}/web"; | ||
179 | }; | ||
180 | in | ||
181 | ludivinecassal | ||