diff options
author | Ismaël Bouya <ismael.bouya@normalesup.org> | 2019-01-01 19:18:08 +0100 |
---|---|---|
committer | Ismaël Bouya <ismael.bouya@normalesup.org> | 2019-01-01 19:18:08 +0100 |
commit | 940f18341ee8f1e86a18a3488c41b5bbef909cd1 (patch) | |
tree | 77df5726342e3b08757db7c7bd6c4300349308a5 /virtual | |
parent | 66b5bbf6214e8b2f599c394c442638257b149b55 (diff) | |
download | Nix-940f18341ee8f1e86a18a3488c41b5bbef909cd1.tar.gz Nix-940f18341ee8f1e86a18a3488c41b5bbef909cd1.tar.zst Nix-940f18341ee8f1e86a18a3488c41b5bbef909cd1.zip |
Move packages to specific files
Diffstat (limited to 'virtual')
-rw-r--r-- | virtual/packages.nix | 515 | ||||
-rw-r--r-- | virtual/packages/adminer.nix | 62 | ||||
-rw-r--r-- | virtual/packages/connexionswing.nix | 170 | ||||
-rw-r--r-- | virtual/packages/connexionswing_master.json (renamed from virtual/connexionswing_master.json) | 0 | ||||
-rw-r--r-- | virtual/packages/nextcloud-config/mimetypealiases.json (renamed from virtual/nextcloudConfig/mimetypealiases.json) | 0 | ||||
-rw-r--r-- | virtual/packages/nextcloud-config/mimetypemapping.json (renamed from virtual/nextcloudConfig/mimetypemapping.json) | 0 | ||||
-rw-r--r-- | virtual/packages/nextcloud.nix | 260 | ||||
-rw-r--r-- | virtual/packages/ympd.nix | 36 |
8 files changed, 532 insertions, 511 deletions
diff --git a/virtual/packages.nix b/virtual/packages.nix index a80c29c..3cfa9b6 100644 --- a/virtual/packages.nix +++ b/virtual/packages.nix | |||
@@ -1,517 +1,10 @@ | |||
1 | with import ../libs.nix; | 1 | with import ../libs.nix; |
2 | with nixpkgs_unstable; | 2 | with nixpkgs_unstable; |
3 | let | 3 | let |
4 | connexionswing = { environment ? "dev" }: rec { | 4 | connexionswing = import ./packages/connexionswing.nix; |
5 | varDir = "/var/lib/connexionswing_${environment}"; | 5 | nextcloud = import ./packages/nextcloud.nix; |
6 | envName= lib.strings.toUpper environment; | 6 | adminer = import ./packages/adminer.nix; |
7 | configRoot = | 7 | ympd = import ./packages/ympd.nix; |
8 | # FIXME: spool emails in prod for when immae.eu is down? | ||
9 | assert checkEnv "NIXOPS_CONNEXIONSWING_${envName}_MYSQL_PASSWORD"; | ||
10 | assert checkEnv "NIXOPS_CONNEXIONSWING_${envName}_MYSQL_USER"; | ||
11 | assert checkEnv "NIXOPS_CONNEXIONSWING_${envName}_MYSQL_NAME"; | ||
12 | assert checkEnv "NIXOPS_CONNEXIONSWING_${envName}_SECRET"; | ||
13 | assert checkEnv "NIXOPS_CONNEXIONSWING_${envName}_EMAIL"; | ||
14 | pkgs.writeText "parameters.yml" '' | ||
15 | # This file is auto-generated during the composer install | ||
16 | parameters: | ||
17 | database_host: db-1.immae.eu | ||
18 | database_port: null | ||
19 | database_name: ${builtins.getEnv "NIXOPS_CONNEXIONSWING_${envName}_MYSQL_NAME"} | ||
20 | database_user: ${builtins.getEnv "NIXOPS_CONNEXIONSWING_${envName}_MYSQL_USER"} | ||
21 | database_password: ${builtins.getEnv "NIXOPS_CONNEXIONSWING_${envName}_MYSQL_PASSWORD"} | ||
22 | mailer_transport: smtp | ||
23 | mailer_host: mail.immae.eu | ||
24 | mailer_user: null | ||
25 | mailer_password: null | ||
26 | subscription_email: ${builtins.getEnv "NIXOPS_CONNEXIONSWING_${envName}_EMAIL"} | ||
27 | allow_robots: true | ||
28 | secret: ${builtins.getEnv "NIXOPS_CONNEXIONSWING_${envName}_SECRET"} | ||
29 | ''; | ||
30 | phpFpm = rec { | ||
31 | socket = "/var/run/phpfpm/connexionswing-${environment}.sock"; | ||
32 | pool = '' | ||
33 | listen = ${socket} | ||
34 | user = ${apache.user} | ||
35 | group = ${apache.group} | ||
36 | listen.owner = ${apache.user} | ||
37 | listen.group = ${apache.group} | ||
38 | php_admin_value[upload_max_filesize] = 20M | ||
39 | php_admin_value[post_max_size] = 20M | ||
40 | ;php_admin_flag[log_errors] = on | ||
41 | php_admin_value[open_basedir] = "${configRoot}:${webappDir}:${varDir}:/tmp" | ||
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 | ''; | ||
125 | }; | ||
126 | activationScript = { | ||
127 | deps = [ "wrappers" ]; | ||
128 | text = '' | ||
129 | install -m 0755 -o ${apache.user} -g ${apache.group} -d ${varDir} \ | ||
130 | ${varDir}/medias \ | ||
131 | ${varDir}/uploads \ | ||
132 | ${varDir}/var | ||
133 | if [ ! -f "${varDir}/currentWebappDir" -o \ | ||
134 | "${webappDir}" != "$(cat ${varDir}/currentWebappDir 2>/dev/null)" ]; then | ||
135 | pushd ${webappDir} > /dev/null | ||
136 | $wrapperDir/sudo -u wwwrun ./bin/console --env=${environment} cache:clear --no-warmup | ||
137 | popd > /dev/null | ||
138 | echo -n "${webappDir}" > ${varDir}/currentWebappDir | ||
139 | fi | ||
140 | ''; | ||
141 | }; | ||
142 | webappDir = pkgs.stdenv.mkDerivation (fetchedGitPrivate ./connexionswing_master.json // rec { | ||
143 | # FIXME: can we do better than symlink? | ||
144 | # FIXME: imagick optional | ||
145 | # FIXME: initial sync | ||
146 | # FIXME: backup | ||
147 | buildPhase = '' | ||
148 | export GIT_SSL_CAINFO=${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt | ||
149 | export SSL_CERT_FILE=${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt | ||
150 | |||
151 | ln -sf ../../../../../${varDir}/{medias,uploads} web/images/ | ||
152 | ln -sf ${configRoot} app/config/parameters.yml | ||
153 | ${if environment == "dev" then "php bin/composer install" else '' | ||
154 | SYMFONY_ENV=prod php bin/composer install --no-dev | ||
155 | ./bin/console assetic:dump --env=prod --no-debug | ||
156 | ''} | ||
157 | rm -rf var | ||
158 | ln -sf ../../../../../${varDir}/var var | ||
159 | ''; | ||
160 | installPhase = '' | ||
161 | cp -a . $out | ||
162 | ''; | ||
163 | buildInputs = [ | ||
164 | pkgs.php pkgs.git pkgs.cacert | ||
165 | ]; | ||
166 | }); | ||
167 | webRoot = "${webappDir}/web"; | ||
168 | }; | ||
169 | |||
170 | nextcloud = let | ||
171 | # FIXME: initial sync | ||
172 | # FIXME: backup | ||
173 | buildApp = { appName, version, url, sha256, installPhase ? "mkdir -p $out && cp -R . $out/" }: | ||
174 | pkgs.stdenv.mkDerivation rec { | ||
175 | name = "nextcloud-app-${appName}-${version}"; | ||
176 | inherit version; | ||
177 | phases = "unpackPhase installPhase"; | ||
178 | inherit installPhase; | ||
179 | src = fetchurl { inherit url sha256; }; | ||
180 | }; | ||
181 | apps = { | ||
182 | # FIXME: nextcloud complains that he cannot write into config | ||
183 | # directory when an app needs upgrade | ||
184 | # /!\ Attention, just changing the version number is not | ||
185 | # sufficient when the downloaded file doesn’t contain the version | ||
186 | # number in it, sha256 needs to be recomputed | ||
187 | audioplayer = buildApp rec { | ||
188 | appName = "audioplayer"; | ||
189 | version = "2.5.0"; | ||
190 | url = "https://github.com/Rello/${appName}/releases/download/${version}/${appName}-${version}.tar.gz"; | ||
191 | sha256 = "1pg4y51cv3agy28n4gfc8i7x1ya1yijxrmhpblm1n846vhmwdcm8"; | ||
192 | }; | ||
193 | bookmarks = buildApp rec { | ||
194 | appName = "bookmarks"; | ||
195 | version = "0.14.3"; | ||
196 | url = "https://github.com/nextcloud/${appName}/releases/download/v${version}/${appName}-${version}.tar.gz"; | ||
197 | sha256 = "0s7lkcl70izlkihnml1par0cac0wvckllyyga3jkb7k9vdg7d40c"; | ||
198 | }; | ||
199 | calendar = buildApp rec { | ||
200 | appName = "calendar"; | ||
201 | version = "1.6.4"; | ||
202 | url = "https://github.com/nextcloud/${appName}/releases/download/v${version}/${appName}.tar.gz"; | ||
203 | sha256 = "00dijvcvy7snsjslfbyzvpp9anhms22zp1f0zkj89ln33jmana63"; | ||
204 | }; | ||
205 | contacts = buildApp rec { | ||
206 | appName = "contacts"; | ||
207 | version = "3.0.0"; | ||
208 | url = "https://github.com/nextcloud/${appName}/releases/download/v${version}/${appName}.tar.gz"; | ||
209 | sha256 = "0fafy5kgzr5ldr3hxxxgmnw4y3qpjnv5ha1f1dlmqbc65s8frw7s"; | ||
210 | }; | ||
211 | deck = buildApp rec { | ||
212 | appName = "deck"; | ||
213 | version = "0.5.2"; | ||
214 | url = "https://github.com/nextcloud/${appName}/releases/download/v${version}/${appName}.tar.gz"; | ||
215 | sha256 = "1kygzixxdkp3dbma009p3pw0fj8wgcqcv39n7pay78lh6zi3nic7"; | ||
216 | }; | ||
217 | files_markdown = buildApp rec { | ||
218 | appName = "files_markdown"; | ||
219 | version = "2.0.5"; | ||
220 | url = "https://github.com/icewind1991/${appName}/releases/download/v${version}/${appName}.tar.gz"; | ||
221 | sha256 = "1dzvy4c6vff2qmkwqw13dx92xdkafaxgnipswjw44mh0ncc2n9ym"; | ||
222 | }; | ||
223 | gpxedit = buildApp rec { | ||
224 | appName = "gpxedit"; | ||
225 | version = "0.0.10"; | ||
226 | url = "https://gitlab.com/eneiluj/gpxedit-oc/wikis/uploads/33d187268c5f6f6a55350d656305701c/${appName}-${version}.tar.gz"; | ||
227 | sha256 = "0ynpaxm0xhvcj8xax6rm1w0p6j57wbqidhi7bhn268n483gwl2sw"; | ||
228 | }; | ||
229 | gpxpod = buildApp rec { | ||
230 | appName = "gpxpod"; | ||
231 | version = "3.0.0"; | ||
232 | url = "https://gitlab.com/eneiluj/gpxpod-oc/-/archive/v${version}/${appName}-oc-v${version}.tar.gz"; | ||
233 | sha256 = "0smpi4r3z7zfl1612fb30cwm1xmpiq95c81zzqiwzjf288iys74k"; | ||
234 | }; | ||
235 | keeweb = buildApp rec { | ||
236 | appName = "keeweb"; | ||
237 | version = "0.4.0"; | ||
238 | url = "https://github.com/jhass/nextcloud-keeweb/releases/download/v${version}/${appName}-${version}.tar.gz"; | ||
239 | sha256 = "0453kkb0a8vfivmibpwpx4bvhyn64jhns6cdfjacmnvbm6d75nj1"; | ||
240 | }; | ||
241 | notes = buildApp rec { | ||
242 | appName = "notes"; | ||
243 | version = "2.5.1"; | ||
244 | url = "https://github.com/nextcloud/${appName}/releases/download/v${version}/${appName}.tar.gz"; | ||
245 | sha256 = "1albzqqsdirzyw8vhvs7r0qm2wqp8vm9vmxm4crhncd85bk01hmh"; | ||
246 | }; | ||
247 | ocsms = buildApp rec { | ||
248 | appName = "ocsms"; | ||
249 | version = "2.1.0"; | ||
250 | url = "https://github.com/nextcloud/${appName}/releases/download/${version}/${appName}-${version}.tar.gz"; | ||
251 | sha256 = "19xgs82js4sdf6j9478vg9li7za7csvcaa1hbq9nmrq441sbxk9c"; | ||
252 | }; | ||
253 | spreed = buildApp rec { | ||
254 | appName = "spreed"; | ||
255 | version = "5.0.0"; | ||
256 | url = "https://github.com/nextcloud/${appName}/releases/download/v${version}/${appName}-${version}.tar.gz"; | ||
257 | sha256 = "1d48mak1fnf1b28r2687yqamm4pxfg3qyxcj9ny31a6xg2cm0xa7"; | ||
258 | }; | ||
259 | tasks = buildApp rec { | ||
260 | appName = "tasks"; | ||
261 | version = "0.9.8"; | ||
262 | url = "https://github.com/nextcloud/${appName}/releases/download/v${version}/${appName}.tar.gz"; | ||
263 | sha256 = "089m124lfsfk09fqj50x9n7zndq97jp5afgb8s001rpmzym4g6ny"; | ||
264 | }; | ||
265 | }; | ||
266 | in rec { | ||
267 | varDir = "/var/lib/nextcloud"; | ||
268 | config_php = | ||
269 | assert checkEnv "NIXOPS_NEXTCLOUD_PASSWORD_SALT"; | ||
270 | assert checkEnv "NIXOPS_NEXTCLOUD_DB_USER"; | ||
271 | assert checkEnv "NIXOPS_NEXTCLOUD_DB_PASSWORD"; | ||
272 | assert checkEnv "NIXOPS_NEXTCLOUD_INSTANCE_ID"; | ||
273 | assert checkEnv "NIXOPS_NEXTCLOUD_SECRET"; | ||
274 | assert checkEnv "NIXOPS_NEXTCLOUD_REDIS_DB_INDEX"; | ||
275 | pkgs.writeText "config.php" '' | ||
276 | <?php | ||
277 | $CONFIG = array ( | ||
278 | 'instanceid' => '${builtins.getEnv "NIXOPS_NEXTCLOUD_INSTANCE_ID"}', | ||
279 | 'datadirectory' => '/var/lib/nextcloud/', | ||
280 | 'passwordsalt' => '${builtins.getEnv "NIXOPS_NEXTCLOUD_PASSWORD_SALT"}', | ||
281 | 'debug' => false, | ||
282 | 'dbtype' => 'pgsql', | ||
283 | 'version' => '15.0.0.10', | ||
284 | 'dbname' => 'webapps', | ||
285 | 'dbhost' => '/tmp', | ||
286 | 'dbtableprefix' => 'oc_', | ||
287 | 'dbuser' => '${builtins.getEnv "NIXOPS_NEXTCLOUD_DB_USER"}', | ||
288 | 'dbpassword' => '${builtins.getEnv "NIXOPS_NEXTCLOUD_DB_PASSWORD"}', | ||
289 | 'installed' => true, | ||
290 | 'maxZipInputSize' => 0, | ||
291 | 'allowZipDownload' => true, | ||
292 | 'forcessl' => true, | ||
293 | 'theme' => ${"''"}, | ||
294 | 'maintenance' => false, | ||
295 | 'trusted_domains' => | ||
296 | array ( | ||
297 | 0 => 'cloud.immae.eu', | ||
298 | ), | ||
299 | 'secret' => '${builtins.getEnv "NIXOPS_NEXTCLOUD_SECRET"}', | ||
300 | 'appstoreenabled' => false, | ||
301 | 'appstore.experimental.enabled' => true, | ||
302 | 'loglevel' => 0, | ||
303 | 'trashbin_retention_obligation' => 'auto', | ||
304 | 'htaccess.RewriteBase' => '/', | ||
305 | 'mail_smtpmode' => 'smtp', | ||
306 | 'mail_smtphost' => 'mail.immae.eu', | ||
307 | 'mail_smtpname' => ${"''"}, | ||
308 | 'mail_smtppassword' => ${"''"}, | ||
309 | 'mail_from_address' => 'owncloud', | ||
310 | 'mail_smtpauth' => false, | ||
311 | 'mail_domain' => 'immae.eu', | ||
312 | 'memcache.local' => '\\OC\\Memcache\\APCu', | ||
313 | 'memcache.locking' => '\\OC\\Memcache\\Redis', | ||
314 | 'filelocking.enabled' => true, | ||
315 | 'redis' => | ||
316 | array ( | ||
317 | 'host' => 'localhost', | ||
318 | 'port' => 6379, | ||
319 | 'dbindex' => ${builtins.getEnv "NIXOPS_NEXTCLOUD_REDIS_DB_INDEX"}, | ||
320 | ), | ||
321 | 'overwrite.cli.url' => 'https://cloud.immae.eu', | ||
322 | 'ldapIgnoreNamingRules' => false, | ||
323 | 'ldapProviderFactory' => '\\OCA\\User_LDAP\\LDAPProviderFactory', | ||
324 | 'config_is_read_only' => true, | ||
325 | ); | ||
326 | ''; | ||
327 | config = stdenv.mkDerivation rec { | ||
328 | name = "nextcloud-config"; | ||
329 | src = ./nextcloudConfig; | ||
330 | phases = "installPhase"; | ||
331 | installPhase = '' | ||
332 | mkdir -p $out | ||
333 | cp -r $src/* $out | ||
334 | cp ${config_php} $out/config.php | ||
335 | ''; | ||
336 | }; | ||
337 | webRoot = stdenv.mkDerivation rec { | ||
338 | name = "nextcloud-${version}"; | ||
339 | version = "15.0.0"; | ||
340 | |||
341 | src = fetchurl { | ||
342 | url = "https://download.nextcloud.com/server/releases/${name}.tar.bz2"; | ||
343 | sha256 = "0y7bk1588n5rmmranmmrkajh50074460hr4v052ahg9mf60wbc2v"; | ||
344 | }; | ||
345 | |||
346 | installPhase = '' | ||
347 | mkdir -p $out/ | ||
348 | cp -R . $out/ | ||
349 | rm -r $out/config | ||
350 | ln -sf ${config} $out/config | ||
351 | ${builtins.concatStringsSep "\n" ( | ||
352 | pkgs.lib.attrsets.mapAttrsToList (name: value: "ln -sf ${value} $out/apps/${name}") apps | ||
353 | )} | ||
354 | ''; | ||
355 | |||
356 | meta = { | ||
357 | description = "Sharing solution for files, calendars, contacts and more"; | ||
358 | homepage = https://nextcloud.com; | ||
359 | maintainers = with stdenv.lib.maintainers; [ schneefux bachp globin fpletz ]; | ||
360 | license = stdenv.lib.licenses.agpl3Plus; | ||
361 | platforms = with stdenv.lib.platforms; unix; | ||
362 | }; | ||
363 | }; | ||
364 | activationScript = { | ||
365 | deps = [ ]; | ||
366 | text = '' | ||
367 | install -m 0755 -o ${apache.user} -g ${apache.group} -d ${varDir} | ||
368 | ''; | ||
369 | }; | ||
370 | apache = { | ||
371 | user = "wwwrun"; | ||
372 | group = "wwwrun"; | ||
373 | modules = [ "proxy_fcgi" ]; | ||
374 | vhostConf = '' | ||
375 | <Directory ${webRoot}> | ||
376 | AcceptPathInfo On | ||
377 | DirectoryIndex index.php | ||
378 | Options FollowSymlinks | ||
379 | Require all granted | ||
380 | AllowOverride all | ||
381 | |||
382 | <IfModule mod_headers.c> | ||
383 | Header always set Strict-Transport-Security "max-age=15552000; includeSubDomains; preload" | ||
384 | </IfModule> | ||
385 | <FilesMatch "\.php$"> | ||
386 | CGIPassAuth on | ||
387 | SetHandler "proxy:unix:${phpFpm.socket}|fcgi://localhost" | ||
388 | </FilesMatch> | ||
389 | |||
390 | </Directory> | ||
391 | |||
392 | ''; | ||
393 | }; | ||
394 | phpFpm = rec { | ||
395 | basedir = builtins.concatStringsSep ":" ( | ||
396 | [ webRoot varDir config ] | ||
397 | ++ pkgs.lib.attrsets.mapAttrsToList (name: value: value) apps); | ||
398 | socket = "/var/run/phpfpm/nextcloud.sock"; | ||
399 | pool = '' | ||
400 | listen = ${socket} | ||
401 | user = ${apache.user} | ||
402 | group = ${apache.group} | ||
403 | listen.owner = ${apache.user} | ||
404 | listen.group = ${apache.group} | ||
405 | pm = ondemand | ||
406 | pm.max_children = 60 | ||
407 | pm.process_idle_timeout = 60 | ||
408 | |||
409 | php_admin_value[output_buffering] = 0 | ||
410 | php_admin_value[max_execution_time] = 1800 | ||
411 | php_admin_value[zend_extension] = "opcache" | ||
412 | ;php_value[opcache.enable] = 1 | ||
413 | php_value[opcache.enable_cli] = 1 | ||
414 | php_value[opcache.interned_strings_buffer] = 8 | ||
415 | php_value[opcache.max_accelerated_files] = 10000 | ||
416 | php_value[opcache.memory_consumption] = 128 | ||
417 | php_value[opcache.save_comments] = 1 | ||
418 | php_value[opcache.revalidate_freq] = 1 | ||
419 | php_admin_value[memory_limit] = 512M | ||
420 | |||
421 | php_admin_value[open_basedir] = "${basedir}:/proc/meminfo:/dev/urandom:/proc/self/fd:/tmp" | ||
422 | ''; | ||
423 | }; | ||
424 | }; | ||
425 | |||
426 | adminer = rec { | ||
427 | webRoot = pkgs.stdenv.mkDerivation rec { | ||
428 | version = "4.7.0"; | ||
429 | name = "adminer-${version}"; | ||
430 | src = pkgs.fetchurl { | ||
431 | url = "https://www.adminer.org/static/download/${version}/${name}.php"; | ||
432 | sha256 = "1qq2g7rbfh2vrqfm3g0bz0qs057b049n0mhabnsbd1sgnpvnc5z7"; | ||
433 | }; | ||
434 | phases = "installPhase"; | ||
435 | installPhase = '' | ||
436 | mkdir -p $out | ||
437 | cp $src $out/index.php | ||
438 | ''; | ||
439 | }; | ||
440 | phpFpm = rec { | ||
441 | socket = "/var/run/phpfpm/adminer.sock"; | ||
442 | pool = '' | ||
443 | listen = ${socket} | ||
444 | user = ${apache.user} | ||
445 | group = ${apache.group} | ||
446 | listen.owner = ${apache.user} | ||
447 | listen.group = ${apache.group} | ||
448 | pm = ondemand | ||
449 | pm.max_children = 5 | ||
450 | pm.process_idle_timeout = 60 | ||
451 | ;php_admin_flag[log_errors] = on | ||
452 | php_admin_value[open_basedir] = "${webRoot}:/tmp" | ||
453 | ''; | ||
454 | }; | ||
455 | apache = { | ||
456 | user = "wwwrun"; | ||
457 | group = "wwwrun"; | ||
458 | modules = [ "proxy_fcgi" ]; | ||
459 | vhostConf = '' | ||
460 | Alias /adminer ${webRoot} | ||
461 | <Directory ${webRoot}> | ||
462 | DirectoryIndex = index.php | ||
463 | <FilesMatch "\.php$"> | ||
464 | SetHandler "proxy:unix:${phpFpm.socket}|fcgi://localhost" | ||
465 | </FilesMatch> | ||
466 | </Directory> | ||
467 | ''; | ||
468 | }; | ||
469 | nginxConf = { | ||
470 | alias = webRoot; | ||
471 | index = "index.php"; | ||
472 | extraConfig = '' | ||
473 | include ${pkgs.nginx}/conf/fastcgi.conf; | ||
474 | fastcgi_split_path_info ^(.+?\.php)(/.*)$; | ||
475 | fastcgi_param HTTP_PROXY ""; | ||
476 | fastcgi_param SCRIPT_FILENAME ${webRoot}/index.php; | ||
477 | fastcgi_pass unix:${phpFpm.socket}; | ||
478 | fastcgi_index index.php; | ||
479 | fastcgi_intercept_errors on; | ||
480 | ''; | ||
481 | }; | ||
482 | }; | ||
483 | |||
484 | ympd = rec { | ||
485 | config = { | ||
486 | webPort = "localhost:18001"; | ||
487 | mpd = { | ||
488 | host = "malige.home.immae.eu"; | ||
489 | port = 6600; | ||
490 | }; | ||
491 | }; | ||
492 | apache = { | ||
493 | modules = [ | ||
494 | "proxy_wstunnel" | ||
495 | ]; | ||
496 | vhostConf = '' | ||
497 | <LocationMatch "^/mpd"> | ||
498 | Use LDAPConnect | ||
499 | Require ldap-group cn=users,cn=mpd,ou=services,dc=immae,dc=eu | ||
500 | Require local | ||
501 | </LocationMatch> | ||
502 | |||
503 | RedirectMatch permanent "^/mpd$" "/mpd/" | ||
504 | <Location "/mpd/"> | ||
505 | ProxyPass http://${config.webPort}/ | ||
506 | ProxyPassReverse http://${config.webPort}/ | ||
507 | ProxyPreserveHost on | ||
508 | </Location> | ||
509 | <Location "/mpd/ws"> | ||
510 | ProxyPass ws://${config.webPort}/ws | ||
511 | </Location> | ||
512 | ''; | ||
513 | }; | ||
514 | }; | ||
515 | in | 8 | in |
516 | { | 9 | { |
517 | inherit adminer; | 10 | inherit adminer; |
diff --git a/virtual/packages/adminer.nix b/virtual/packages/adminer.nix new file mode 100644 index 0000000..35fa791 --- /dev/null +++ b/virtual/packages/adminer.nix | |||
@@ -0,0 +1,62 @@ | |||
1 | with import ../../libs.nix; | ||
2 | with nixpkgs_unstable; | ||
3 | let | ||
4 | adminer = rec { | ||
5 | webRoot = pkgs.stdenv.mkDerivation rec { | ||
6 | version = "4.7.0"; | ||
7 | name = "adminer-${version}"; | ||
8 | src = pkgs.fetchurl { | ||
9 | url = "https://www.adminer.org/static/download/${version}/${name}.php"; | ||
10 | sha256 = "1qq2g7rbfh2vrqfm3g0bz0qs057b049n0mhabnsbd1sgnpvnc5z7"; | ||
11 | }; | ||
12 | phases = "installPhase"; | ||
13 | installPhase = '' | ||
14 | mkdir -p $out | ||
15 | cp $src $out/index.php | ||
16 | ''; | ||
17 | }; | ||
18 | phpFpm = rec { | ||
19 | socket = "/var/run/phpfpm/adminer.sock"; | ||
20 | pool = '' | ||
21 | listen = ${socket} | ||
22 | user = ${apache.user} | ||
23 | group = ${apache.group} | ||
24 | listen.owner = ${apache.user} | ||
25 | listen.group = ${apache.group} | ||
26 | pm = ondemand | ||
27 | pm.max_children = 5 | ||
28 | pm.process_idle_timeout = 60 | ||
29 | ;php_admin_flag[log_errors] = on | ||
30 | php_admin_value[open_basedir] = "${webRoot}:/tmp" | ||
31 | ''; | ||
32 | }; | ||
33 | apache = { | ||
34 | user = "wwwrun"; | ||
35 | group = "wwwrun"; | ||
36 | modules = [ "proxy_fcgi" ]; | ||
37 | vhostConf = '' | ||
38 | Alias /adminer ${webRoot} | ||
39 | <Directory ${webRoot}> | ||
40 | DirectoryIndex = index.php | ||
41 | <FilesMatch "\.php$"> | ||
42 | SetHandler "proxy:unix:${phpFpm.socket}|fcgi://localhost" | ||
43 | </FilesMatch> | ||
44 | </Directory> | ||
45 | ''; | ||
46 | }; | ||
47 | nginxConf = { | ||
48 | alias = webRoot; | ||
49 | index = "index.php"; | ||
50 | extraConfig = '' | ||
51 | include ${pkgs.nginx}/conf/fastcgi.conf; | ||
52 | fastcgi_split_path_info ^(.+?\.php)(/.*)$; | ||
53 | fastcgi_param HTTP_PROXY ""; | ||
54 | fastcgi_param SCRIPT_FILENAME ${webRoot}/index.php; | ||
55 | fastcgi_pass unix:${phpFpm.socket}; | ||
56 | fastcgi_index index.php; | ||
57 | fastcgi_intercept_errors on; | ||
58 | ''; | ||
59 | }; | ||
60 | }; | ||
61 | in | ||
62 | adminer | ||
diff --git a/virtual/packages/connexionswing.nix b/virtual/packages/connexionswing.nix new file mode 100644 index 0000000..a0f5fa6 --- /dev/null +++ b/virtual/packages/connexionswing.nix | |||
@@ -0,0 +1,170 @@ | |||
1 | with import ../../libs.nix; | ||
2 | with nixpkgs_unstable; | ||
3 | let | ||
4 | connexionswing = { environment ? "dev" }: rec { | ||
5 | varDir = "/var/lib/connexionswing_${environment}"; | ||
6 | envName= lib.strings.toUpper environment; | ||
7 | configRoot = | ||
8 | # FIXME: spool emails in prod for when immae.eu is down? | ||
9 | assert checkEnv "NIXOPS_CONNEXIONSWING_${envName}_MYSQL_PASSWORD"; | ||
10 | assert checkEnv "NIXOPS_CONNEXIONSWING_${envName}_MYSQL_USER"; | ||
11 | assert checkEnv "NIXOPS_CONNEXIONSWING_${envName}_MYSQL_NAME"; | ||
12 | assert checkEnv "NIXOPS_CONNEXIONSWING_${envName}_SECRET"; | ||
13 | assert checkEnv "NIXOPS_CONNEXIONSWING_${envName}_EMAIL"; | ||
14 | pkgs.writeText "parameters.yml" '' | ||
15 | # This file is auto-generated during the composer install | ||
16 | parameters: | ||
17 | database_host: db-1.immae.eu | ||
18 | database_port: null | ||
19 | database_name: ${builtins.getEnv "NIXOPS_CONNEXIONSWING_${envName}_MYSQL_NAME"} | ||
20 | database_user: ${builtins.getEnv "NIXOPS_CONNEXIONSWING_${envName}_MYSQL_USER"} | ||
21 | database_password: ${builtins.getEnv "NIXOPS_CONNEXIONSWING_${envName}_MYSQL_PASSWORD"} | ||
22 | mailer_transport: smtp | ||
23 | mailer_host: mail.immae.eu | ||
24 | mailer_user: null | ||
25 | mailer_password: null | ||
26 | subscription_email: ${builtins.getEnv "NIXOPS_CONNEXIONSWING_${envName}_EMAIL"} | ||
27 | allow_robots: true | ||
28 | secret: ${builtins.getEnv "NIXOPS_CONNEXIONSWING_${envName}_SECRET"} | ||
29 | ''; | ||
30 | phpFpm = rec { | ||
31 | socket = "/var/run/phpfpm/connexionswing-${environment}.sock"; | ||
32 | pool = '' | ||
33 | listen = ${socket} | ||
34 | user = ${apache.user} | ||
35 | group = ${apache.group} | ||
36 | listen.owner = ${apache.user} | ||
37 | listen.group = ${apache.group} | ||
38 | php_admin_value[upload_max_filesize] = 20M | ||
39 | php_admin_value[post_max_size] = 20M | ||
40 | ;php_admin_flag[log_errors] = on | ||
41 | php_admin_value[open_basedir] = "${configRoot}:${webappDir}:${varDir}:/tmp" | ||
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 | ''; | ||
125 | }; | ||
126 | activationScript = { | ||
127 | deps = [ "wrappers" ]; | ||
128 | text = '' | ||
129 | install -m 0755 -o ${apache.user} -g ${apache.group} -d ${varDir} \ | ||
130 | ${varDir}/medias \ | ||
131 | ${varDir}/uploads \ | ||
132 | ${varDir}/var | ||
133 | if [ ! -f "${varDir}/currentWebappDir" -o \ | ||
134 | "${webappDir}" != "$(cat ${varDir}/currentWebappDir 2>/dev/null)" ]; then | ||
135 | pushd ${webappDir} > /dev/null | ||
136 | $wrapperDir/sudo -u wwwrun ./bin/console --env=${environment} cache:clear --no-warmup | ||
137 | popd > /dev/null | ||
138 | echo -n "${webappDir}" > ${varDir}/currentWebappDir | ||
139 | fi | ||
140 | ''; | ||
141 | }; | ||
142 | webappDir = pkgs.stdenv.mkDerivation (fetchedGitPrivate ./connexionswing_master.json // rec { | ||
143 | # FIXME: can we do better than symlink? | ||
144 | # FIXME: imagick optional | ||
145 | # FIXME: initial sync | ||
146 | # FIXME: backup | ||
147 | buildPhase = '' | ||
148 | export GIT_SSL_CAINFO=${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt | ||
149 | export SSL_CERT_FILE=${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt | ||
150 | |||
151 | ln -sf ../../../../../${varDir}/{medias,uploads} web/images/ | ||
152 | ln -sf ${configRoot} app/config/parameters.yml | ||
153 | ${if environment == "dev" then "php bin/composer install" else '' | ||
154 | SYMFONY_ENV=prod php bin/composer install --no-dev | ||
155 | ./bin/console assetic:dump --env=prod --no-debug | ||
156 | ''} | ||
157 | rm -rf var | ||
158 | ln -sf ../../../../../${varDir}/var var | ||
159 | ''; | ||
160 | installPhase = '' | ||
161 | cp -a . $out | ||
162 | ''; | ||
163 | buildInputs = [ | ||
164 | pkgs.php pkgs.git pkgs.cacert | ||
165 | ]; | ||
166 | }); | ||
167 | webRoot = "${webappDir}/web"; | ||
168 | }; | ||
169 | in | ||
170 | connexionswing | ||
diff --git a/virtual/connexionswing_master.json b/virtual/packages/connexionswing_master.json index 30c0c96..30c0c96 100644 --- a/virtual/connexionswing_master.json +++ b/virtual/packages/connexionswing_master.json | |||
diff --git a/virtual/nextcloudConfig/mimetypealiases.json b/virtual/packages/nextcloud-config/mimetypealiases.json index 3806e53..3806e53 100644 --- a/virtual/nextcloudConfig/mimetypealiases.json +++ b/virtual/packages/nextcloud-config/mimetypealiases.json | |||
diff --git a/virtual/nextcloudConfig/mimetypemapping.json b/virtual/packages/nextcloud-config/mimetypemapping.json index 2db4691..2db4691 100644 --- a/virtual/nextcloudConfig/mimetypemapping.json +++ b/virtual/packages/nextcloud-config/mimetypemapping.json | |||
diff --git a/virtual/packages/nextcloud.nix b/virtual/packages/nextcloud.nix new file mode 100644 index 0000000..99130e4 --- /dev/null +++ b/virtual/packages/nextcloud.nix | |||
@@ -0,0 +1,260 @@ | |||
1 | with import ../../libs.nix; | ||
2 | with nixpkgs_unstable; | ||
3 | let | ||
4 | nextcloud = let | ||
5 | # FIXME: initial sync | ||
6 | # FIXME: backup | ||
7 | buildApp = { appName, version, url, sha256, installPhase ? "mkdir -p $out && cp -R . $out/" }: | ||
8 | pkgs.stdenv.mkDerivation rec { | ||
9 | name = "nextcloud-app-${appName}-${version}"; | ||
10 | inherit version; | ||
11 | phases = "unpackPhase installPhase"; | ||
12 | inherit installPhase; | ||
13 | src = fetchurl { inherit url sha256; }; | ||
14 | }; | ||
15 | apps = { | ||
16 | # FIXME: nextcloud complains that he cannot write into config | ||
17 | # directory when an app needs upgrade | ||
18 | # /!\ Attention, just changing the version number is not | ||
19 | # sufficient when the downloaded file doesn’t contain the version | ||
20 | # number in it, sha256 needs to be recomputed | ||
21 | audioplayer = buildApp rec { | ||
22 | appName = "audioplayer"; | ||
23 | version = "2.5.0"; | ||
24 | url = "https://github.com/Rello/${appName}/releases/download/${version}/${appName}-${version}.tar.gz"; | ||
25 | sha256 = "1pg4y51cv3agy28n4gfc8i7x1ya1yijxrmhpblm1n846vhmwdcm8"; | ||
26 | }; | ||
27 | bookmarks = buildApp rec { | ||
28 | appName = "bookmarks"; | ||
29 | version = "0.14.3"; | ||
30 | url = "https://github.com/nextcloud/${appName}/releases/download/v${version}/${appName}-${version}.tar.gz"; | ||
31 | sha256 = "0s7lkcl70izlkihnml1par0cac0wvckllyyga3jkb7k9vdg7d40c"; | ||
32 | }; | ||
33 | calendar = buildApp rec { | ||
34 | appName = "calendar"; | ||
35 | version = "1.6.4"; | ||
36 | url = "https://github.com/nextcloud/${appName}/releases/download/v${version}/${appName}.tar.gz"; | ||
37 | sha256 = "00dijvcvy7snsjslfbyzvpp9anhms22zp1f0zkj89ln33jmana63"; | ||
38 | }; | ||
39 | contacts = buildApp rec { | ||
40 | appName = "contacts"; | ||
41 | version = "3.0.0"; | ||
42 | url = "https://github.com/nextcloud/${appName}/releases/download/v${version}/${appName}.tar.gz"; | ||
43 | sha256 = "0fafy5kgzr5ldr3hxxxgmnw4y3qpjnv5ha1f1dlmqbc65s8frw7s"; | ||
44 | }; | ||
45 | deck = buildApp rec { | ||
46 | appName = "deck"; | ||
47 | version = "0.5.2"; | ||
48 | url = "https://github.com/nextcloud/${appName}/releases/download/v${version}/${appName}.tar.gz"; | ||
49 | sha256 = "1kygzixxdkp3dbma009p3pw0fj8wgcqcv39n7pay78lh6zi3nic7"; | ||
50 | }; | ||
51 | files_markdown = buildApp rec { | ||
52 | appName = "files_markdown"; | ||
53 | version = "2.0.5"; | ||
54 | url = "https://github.com/icewind1991/${appName}/releases/download/v${version}/${appName}.tar.gz"; | ||
55 | sha256 = "1dzvy4c6vff2qmkwqw13dx92xdkafaxgnipswjw44mh0ncc2n9ym"; | ||
56 | }; | ||
57 | gpxedit = buildApp rec { | ||
58 | appName = "gpxedit"; | ||
59 | version = "0.0.10"; | ||
60 | url = "https://gitlab.com/eneiluj/gpxedit-oc/wikis/uploads/33d187268c5f6f6a55350d656305701c/${appName}-${version}.tar.gz"; | ||
61 | sha256 = "0ynpaxm0xhvcj8xax6rm1w0p6j57wbqidhi7bhn268n483gwl2sw"; | ||
62 | }; | ||
63 | gpxpod = buildApp rec { | ||
64 | appName = "gpxpod"; | ||
65 | version = "3.0.0"; | ||
66 | url = "https://gitlab.com/eneiluj/gpxpod-oc/-/archive/v${version}/${appName}-oc-v${version}.tar.gz"; | ||
67 | sha256 = "0smpi4r3z7zfl1612fb30cwm1xmpiq95c81zzqiwzjf288iys74k"; | ||
68 | }; | ||
69 | keeweb = buildApp rec { | ||
70 | appName = "keeweb"; | ||
71 | version = "0.4.0"; | ||
72 | url = "https://github.com/jhass/nextcloud-keeweb/releases/download/v${version}/${appName}-${version}.tar.gz"; | ||
73 | sha256 = "0453kkb0a8vfivmibpwpx4bvhyn64jhns6cdfjacmnvbm6d75nj1"; | ||
74 | }; | ||
75 | notes = buildApp rec { | ||
76 | appName = "notes"; | ||
77 | version = "2.5.1"; | ||
78 | url = "https://github.com/nextcloud/${appName}/releases/download/v${version}/${appName}.tar.gz"; | ||
79 | sha256 = "1albzqqsdirzyw8vhvs7r0qm2wqp8vm9vmxm4crhncd85bk01hmh"; | ||
80 | }; | ||
81 | ocsms = buildApp rec { | ||
82 | appName = "ocsms"; | ||
83 | version = "2.1.0"; | ||
84 | url = "https://github.com/nextcloud/${appName}/releases/download/${version}/${appName}-${version}.tar.gz"; | ||
85 | sha256 = "19xgs82js4sdf6j9478vg9li7za7csvcaa1hbq9nmrq441sbxk9c"; | ||
86 | }; | ||
87 | spreed = buildApp rec { | ||
88 | appName = "spreed"; | ||
89 | version = "5.0.0"; | ||
90 | url = "https://github.com/nextcloud/${appName}/releases/download/v${version}/${appName}-${version}.tar.gz"; | ||
91 | sha256 = "1d48mak1fnf1b28r2687yqamm4pxfg3qyxcj9ny31a6xg2cm0xa7"; | ||
92 | }; | ||
93 | tasks = buildApp rec { | ||
94 | appName = "tasks"; | ||
95 | version = "0.9.8"; | ||
96 | url = "https://github.com/nextcloud/${appName}/releases/download/v${version}/${appName}.tar.gz"; | ||
97 | sha256 = "089m124lfsfk09fqj50x9n7zndq97jp5afgb8s001rpmzym4g6ny"; | ||
98 | }; | ||
99 | }; | ||
100 | in rec { | ||
101 | varDir = "/var/lib/nextcloud"; | ||
102 | config_php = | ||
103 | assert checkEnv "NIXOPS_NEXTCLOUD_PASSWORD_SALT"; | ||
104 | assert checkEnv "NIXOPS_NEXTCLOUD_DB_USER"; | ||
105 | assert checkEnv "NIXOPS_NEXTCLOUD_DB_PASSWORD"; | ||
106 | assert checkEnv "NIXOPS_NEXTCLOUD_INSTANCE_ID"; | ||
107 | assert checkEnv "NIXOPS_NEXTCLOUD_SECRET"; | ||
108 | assert checkEnv "NIXOPS_NEXTCLOUD_REDIS_DB_INDEX"; | ||
109 | pkgs.writeText "config.php" '' | ||
110 | <?php | ||
111 | $CONFIG = array ( | ||
112 | 'instanceid' => '${builtins.getEnv "NIXOPS_NEXTCLOUD_INSTANCE_ID"}', | ||
113 | 'datadirectory' => '/var/lib/nextcloud/', | ||
114 | 'passwordsalt' => '${builtins.getEnv "NIXOPS_NEXTCLOUD_PASSWORD_SALT"}', | ||
115 | 'debug' => false, | ||
116 | 'dbtype' => 'pgsql', | ||
117 | 'version' => '15.0.0.10', | ||
118 | 'dbname' => 'webapps', | ||
119 | 'dbhost' => '/tmp', | ||
120 | 'dbtableprefix' => 'oc_', | ||
121 | 'dbuser' => '${builtins.getEnv "NIXOPS_NEXTCLOUD_DB_USER"}', | ||
122 | 'dbpassword' => '${builtins.getEnv "NIXOPS_NEXTCLOUD_DB_PASSWORD"}', | ||
123 | 'installed' => true, | ||
124 | 'maxZipInputSize' => 0, | ||
125 | 'allowZipDownload' => true, | ||
126 | 'forcessl' => true, | ||
127 | 'theme' => ${"''"}, | ||
128 | 'maintenance' => false, | ||
129 | 'trusted_domains' => | ||
130 | array ( | ||
131 | 0 => 'cloud.immae.eu', | ||
132 | ), | ||
133 | 'secret' => '${builtins.getEnv "NIXOPS_NEXTCLOUD_SECRET"}', | ||
134 | 'appstoreenabled' => false, | ||
135 | 'appstore.experimental.enabled' => true, | ||
136 | 'loglevel' => 0, | ||
137 | 'trashbin_retention_obligation' => 'auto', | ||
138 | 'htaccess.RewriteBase' => '/', | ||
139 | 'mail_smtpmode' => 'smtp', | ||
140 | 'mail_smtphost' => 'mail.immae.eu', | ||
141 | 'mail_smtpname' => ${"''"}, | ||
142 | 'mail_smtppassword' => ${"''"}, | ||
143 | 'mail_from_address' => 'owncloud', | ||
144 | 'mail_smtpauth' => false, | ||
145 | 'mail_domain' => 'immae.eu', | ||
146 | 'memcache.local' => '\\OC\\Memcache\\APCu', | ||
147 | 'memcache.locking' => '\\OC\\Memcache\\Redis', | ||
148 | 'filelocking.enabled' => true, | ||
149 | 'redis' => | ||
150 | array ( | ||
151 | 'host' => 'localhost', | ||
152 | 'port' => 6379, | ||
153 | 'dbindex' => ${builtins.getEnv "NIXOPS_NEXTCLOUD_REDIS_DB_INDEX"}, | ||
154 | ), | ||
155 | 'overwrite.cli.url' => 'https://cloud.immae.eu', | ||
156 | 'ldapIgnoreNamingRules' => false, | ||
157 | 'ldapProviderFactory' => '\\OCA\\User_LDAP\\LDAPProviderFactory', | ||
158 | 'config_is_read_only' => true, | ||
159 | ); | ||
160 | ''; | ||
161 | config = stdenv.mkDerivation rec { | ||
162 | name = "nextcloud-config"; | ||
163 | src = ./nextcloud-config; | ||
164 | phases = "installPhase"; | ||
165 | installPhase = '' | ||
166 | mkdir -p $out | ||
167 | cp -r $src/* $out | ||
168 | cp ${config_php} $out/config.php | ||
169 | ''; | ||
170 | }; | ||
171 | webRoot = stdenv.mkDerivation rec { | ||
172 | name = "nextcloud-${version}"; | ||
173 | version = "15.0.0"; | ||
174 | |||
175 | src = fetchurl { | ||
176 | url = "https://download.nextcloud.com/server/releases/${name}.tar.bz2"; | ||
177 | sha256 = "0y7bk1588n5rmmranmmrkajh50074460hr4v052ahg9mf60wbc2v"; | ||
178 | }; | ||
179 | |||
180 | installPhase = '' | ||
181 | mkdir -p $out/ | ||
182 | cp -R . $out/ | ||
183 | rm -r $out/config | ||
184 | ln -sf ${config} $out/config | ||
185 | ${builtins.concatStringsSep "\n" ( | ||
186 | pkgs.lib.attrsets.mapAttrsToList (name: value: "ln -sf ${value} $out/apps/${name}") apps | ||
187 | )} | ||
188 | ''; | ||
189 | |||
190 | meta = { | ||
191 | description = "Sharing solution for files, calendars, contacts and more"; | ||
192 | homepage = https://nextcloud.com; | ||
193 | maintainers = with stdenv.lib.maintainers; [ schneefux bachp globin fpletz ]; | ||
194 | license = stdenv.lib.licenses.agpl3Plus; | ||
195 | platforms = with stdenv.lib.platforms; unix; | ||
196 | }; | ||
197 | }; | ||
198 | activationScript = { | ||
199 | deps = [ ]; | ||
200 | text = '' | ||
201 | install -m 0755 -o ${apache.user} -g ${apache.group} -d ${varDir} | ||
202 | ''; | ||
203 | }; | ||
204 | apache = { | ||
205 | user = "wwwrun"; | ||
206 | group = "wwwrun"; | ||
207 | modules = [ "proxy_fcgi" ]; | ||
208 | vhostConf = '' | ||
209 | <Directory ${webRoot}> | ||
210 | AcceptPathInfo On | ||
211 | DirectoryIndex index.php | ||
212 | Options FollowSymlinks | ||
213 | Require all granted | ||
214 | AllowOverride all | ||
215 | |||
216 | <IfModule mod_headers.c> | ||
217 | Header always set Strict-Transport-Security "max-age=15552000; includeSubDomains; preload" | ||
218 | </IfModule> | ||
219 | <FilesMatch "\.php$"> | ||
220 | CGIPassAuth on | ||
221 | SetHandler "proxy:unix:${phpFpm.socket}|fcgi://localhost" | ||
222 | </FilesMatch> | ||
223 | |||
224 | </Directory> | ||
225 | |||
226 | ''; | ||
227 | }; | ||
228 | phpFpm = rec { | ||
229 | basedir = builtins.concatStringsSep ":" ( | ||
230 | [ webRoot varDir config ] | ||
231 | ++ pkgs.lib.attrsets.mapAttrsToList (name: value: value) apps); | ||
232 | socket = "/var/run/phpfpm/nextcloud.sock"; | ||
233 | pool = '' | ||
234 | listen = ${socket} | ||
235 | user = ${apache.user} | ||
236 | group = ${apache.group} | ||
237 | listen.owner = ${apache.user} | ||
238 | listen.group = ${apache.group} | ||
239 | pm = ondemand | ||
240 | pm.max_children = 60 | ||
241 | pm.process_idle_timeout = 60 | ||
242 | |||
243 | php_admin_value[output_buffering] = 0 | ||
244 | php_admin_value[max_execution_time] = 1800 | ||
245 | php_admin_value[zend_extension] = "opcache" | ||
246 | ;php_value[opcache.enable] = 1 | ||
247 | php_value[opcache.enable_cli] = 1 | ||
248 | php_value[opcache.interned_strings_buffer] = 8 | ||
249 | php_value[opcache.max_accelerated_files] = 10000 | ||
250 | php_value[opcache.memory_consumption] = 128 | ||
251 | php_value[opcache.save_comments] = 1 | ||
252 | php_value[opcache.revalidate_freq] = 1 | ||
253 | php_admin_value[memory_limit] = 512M | ||
254 | |||
255 | php_admin_value[open_basedir] = "${basedir}:/proc/meminfo:/dev/urandom:/proc/self/fd:/tmp" | ||
256 | ''; | ||
257 | }; | ||
258 | }; | ||
259 | in | ||
260 | nextcloud | ||
diff --git a/virtual/packages/ympd.nix b/virtual/packages/ympd.nix new file mode 100644 index 0000000..643c860 --- /dev/null +++ b/virtual/packages/ympd.nix | |||
@@ -0,0 +1,36 @@ | |||
1 | with import ../../libs.nix; | ||
2 | with nixpkgs_unstable; | ||
3 | let | ||
4 | ympd = rec { | ||
5 | config = { | ||
6 | webPort = "localhost:18001"; | ||
7 | mpd = { | ||
8 | host = "malige.home.immae.eu"; | ||
9 | port = 6600; | ||
10 | }; | ||
11 | }; | ||
12 | apache = { | ||
13 | modules = [ | ||
14 | "proxy_wstunnel" | ||
15 | ]; | ||
16 | vhostConf = '' | ||
17 | <LocationMatch "^/mpd"> | ||
18 | Use LDAPConnect | ||
19 | Require ldap-group cn=users,cn=mpd,ou=services,dc=immae,dc=eu | ||
20 | Require local | ||
21 | </LocationMatch> | ||
22 | |||
23 | RedirectMatch permanent "^/mpd$" "/mpd/" | ||
24 | <Location "/mpd/"> | ||
25 | ProxyPass http://${config.webPort}/ | ||
26 | ProxyPassReverse http://${config.webPort}/ | ||
27 | ProxyPreserveHost on | ||
28 | </Location> | ||
29 | <Location "/mpd/ws"> | ||
30 | ProxyPass ws://${config.webPort}/ws | ||
31 | </Location> | ||
32 | ''; | ||
33 | }; | ||
34 | }; | ||
35 | in | ||
36 | ympd | ||