aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIsmaël Bouya <ismael.bouya@normalesup.org>2018-12-31 15:35:31 +0100
committerIsmaël Bouya <ismael.bouya@normalesup.org>2019-01-01 18:18:44 +0100
commit66b5bbf6214e8b2f599c394c442638257b149b55 (patch)
tree482ea033619f7fef86916251c3d5f97d31d12883
parent1d4ccb2c4d48bb510ea2cf22ff1b96fc887d8a00 (diff)
downloadNix-66b5bbf6214e8b2f599c394c442638257b149b55.tar.gz
Nix-66b5bbf6214e8b2f599c394c442638257b149b55.tar.zst
Nix-66b5bbf6214e8b2f599c394c442638257b149b55.zip
Add Nextcloud configuration
-rw-r--r--virtual/eldiron.nix33
-rw-r--r--virtual/nextcloudConfig/mimetypealiases.json4
-rw-r--r--virtual/nextcloudConfig/mimetypemapping.json4
-rw-r--r--virtual/packages.nix257
4 files changed, 297 insertions, 1 deletions
diff --git a/virtual/eldiron.nix b/virtual/eldiron.nix
index d90e722..36b765c 100644
--- a/virtual/eldiron.nix
+++ b/virtual/eldiron.nix
@@ -36,9 +36,21 @@
36 }; 36 };
37 }; 37 };
38 38
39 environment.systemPackages = [ 39 environment.systemPackages = let
40 # FIXME: move it to nextcloud
41 occ = pkgs.writeScriptBin "nextcloud-occ" ''
42 #! ${pkgs.stdenv.shell}
43 cd ${mypkgs.nextcloud.webRoot}
44 NEXTCLOUD_CONFIG_DIR="${mypkgs.nextcloud.webRoot}/config" \
45 exec \
46 ${config.services.phpfpm.phpPackage}/bin/php \
47 -c ${config.services.phpfpm.phpPackage}/etc/php.ini \
48 occ $*
49 '';
50 in [
40 pkgs.telnet 51 pkgs.telnet
41 pkgs.vim 52 pkgs.vim
53 occ
42 ]; 54 ];
43 55
44 security.acme.certs = { 56 security.acme.certs = {
@@ -55,6 +67,7 @@
55 "tools.immae.eu" = null; 67 "tools.immae.eu" = null;
56 "connexionswing.immae.eu" = null; 68 "connexionswing.immae.eu" = null;
57 "sandetludo.immae.eu" = null; 69 "sandetludo.immae.eu" = null;
70 "cloud.immae.eu" = null;
58 }; 71 };
59 }; 72 };
60 # "connexionswing" = { 73 # "connexionswing" = {
@@ -76,6 +89,13 @@
76 services.ympd = mypkgs.ympd.config // { enable = true; }; 89 services.ympd = mypkgs.ympd.config // { enable = true; };
77 90
78 services.phpfpm = { 91 services.phpfpm = {
92 # /!\ phppackage is used in nextcloud configuation
93 phpOptions = ''
94 ; For nextcloud
95 extension=${pkgs.phpPackages.redis}/lib/php/extensions/redis.so
96 ; For nextcloud
97 extension=${pkgs.phpPackages.apcu}/lib/php/extensions/apcu.so
98 '';
79 extraConfig = '' 99 extraConfig = ''
80 log_level = notice 100 log_level = notice
81 ''; 101 '';
@@ -83,12 +103,14 @@
83 adminer = mypkgs.adminer.phpFpm.pool; 103 adminer = mypkgs.adminer.phpFpm.pool;
84 connexionswing_dev = mypkgs.connexionswing_dev.phpFpm.pool; 104 connexionswing_dev = mypkgs.connexionswing_dev.phpFpm.pool;
85 connexionswing_prod = mypkgs.connexionswing_prod.phpFpm.pool; 105 connexionswing_prod = mypkgs.connexionswing_prod.phpFpm.pool;
106 nextcloud = mypkgs.nextcloud.phpFpm.pool;
86 }; 107 };
87 }; 108 };
88 109
89 system.activationScripts = { 110 system.activationScripts = {
90 connexionswing_dev = mypkgs.connexionswing_dev.activationScript; 111 connexionswing_dev = mypkgs.connexionswing_dev.activationScript;
91 connexionswing_prod = mypkgs.connexionswing_prod.activationScript; 112 connexionswing_prod = mypkgs.connexionswing_prod.activationScript;
113 nextcloud = mypkgs.nextcloud.activationScript;
92 httpd = '' 114 httpd = ''
93 install -d -m 0755 /var/lib/acme/acme-challenge 115 install -d -m 0755 /var/lib/acme/acme-challenge
94 ''; 116 '';
@@ -160,6 +182,7 @@
160 182
161 extraModules = pkgs.lib.lists.unique ( 183 extraModules = pkgs.lib.lists.unique (
162 mypkgs.adminer.apache.modules ++ 184 mypkgs.adminer.apache.modules ++
185 mypkgs.nextcloud.apache.modules ++
163 mypkgs.connexionswing_dev.apache.modules ++ 186 mypkgs.connexionswing_dev.apache.modules ++
164 mypkgs.connexionswing_prod.apache.modules ++ 187 mypkgs.connexionswing_prod.apache.modules ++
165 mypkgs.ympd.apache.modules ++ 188 mypkgs.ympd.apache.modules ++
@@ -202,6 +225,14 @@
202 mypkgs.connexionswing_dev.apache.vhostConf 225 mypkgs.connexionswing_dev.apache.vhostConf
203 ]; 226 ];
204 }) 227 })
228 (withSSL "eldiron" // {
229 listen = [ { ip = "*"; port = 443; } ];
230 hostName = "cloud.immae.eu";
231 documentRoot = mypkgs.nextcloud.webRoot;
232 extraConfig = builtins.concatStringsSep "\n" [
233 mypkgs.nextcloud.apache.vhostConf
234 ];
235 })
205 { # Should go last, default fallback 236 { # Should go last, default fallback
206 listen = [ { ip = "*"; port = 80; } ]; 237 listen = [ { ip = "*"; port = 80; } ];
207 hostName = "redirectSSL"; 238 hostName = "redirectSSL";
diff --git a/virtual/nextcloudConfig/mimetypealiases.json b/virtual/nextcloudConfig/mimetypealiases.json
new file mode 100644
index 0000000..3806e53
--- /dev/null
+++ b/virtual/nextcloudConfig/mimetypealiases.json
@@ -0,0 +1,4 @@
1{
2 "application/gpx+xml": "gpx",
3 "x-application/kdbx": "kdbx"
4}
diff --git a/virtual/nextcloudConfig/mimetypemapping.json b/virtual/nextcloudConfig/mimetypemapping.json
new file mode 100644
index 0000000..2db4691
--- /dev/null
+++ b/virtual/nextcloudConfig/mimetypemapping.json
@@ -0,0 +1,4 @@
1{
2 "gpx": ["application/gpx+xml"],
3 "kdbx": ["x-application/kdbx"]
4}
diff --git a/virtual/packages.nix b/virtual/packages.nix
index 336caac..a80c29c 100644
--- a/virtual/packages.nix
+++ b/virtual/packages.nix
@@ -167,6 +167,262 @@ let
167 webRoot = "${webappDir}/web"; 167 webRoot = "${webappDir}/web";
168 }; 168 };
169 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
170 adminer = rec { 426 adminer = rec {
171 webRoot = pkgs.stdenv.mkDerivation rec { 427 webRoot = pkgs.stdenv.mkDerivation rec {
172 version = "4.7.0"; 428 version = "4.7.0";
@@ -262,4 +518,5 @@ in
262 inherit ympd; 518 inherit ympd;
263 connexionswing_dev = connexionswing { environment = "dev"; }; 519 connexionswing_dev = connexionswing { environment = "dev"; };
264 connexionswing_prod = connexionswing { environment = "prod"; }; 520 connexionswing_prod = connexionswing { environment = "prod"; };
521 inherit nextcloud;
265 } 522 }