1 { lib, pkgs, config, ... }:
3 phpPackage = (pkgs.php74.withExtensions({ enabled, all }: enabled ++ [ all.redis all.apcu all.opcache all.imagick ])).override { extraConfig = ''
7 nextcloud = pkgs.webapps.nextcloud_22.withApps (a: [ a.calendar a.contacts ]);
8 varDir = "/var/lib/nextcloud";
10 basedir = builtins.concatStringsSep ":" ([ nextcloud varDir ] ++ nextcloud.apps);
12 "listen.owner" = "wwwrun";
13 "listen.group" = "wwwrun";
15 "pm.max_children" = "60";
16 "pm.process_idle_timeout" = "60";
18 "php_admin_value[output_buffering]" = "0";
19 "php_admin_value[max_execution_time]" = "1800";
20 "php_admin_value[zend_extension]" = "opcache";
21 #already enabled by default?
22 #"php_value[opcache.enable]" = "1";
23 "php_value[opcache.enable_cli]" = "1";
24 "php_value[opcache.interned_strings_buffer]" = "8";
25 "php_value[opcache.max_accelerated_files]" = "10000";
26 "php_value[opcache.memory_consumption]" = "128";
27 "php_value[opcache.save_comments]" = "1";
28 "php_value[opcache.revalidate_freq]" = "1";
29 "php_admin_value[memory_limit]" = "512M";
31 "php_admin_value[open_basedir]" = "/run/wrappers/bin/sendmail:${basedir}:/proc/meminfo:/dev/urandom:/proc/self/fd:/tmp";
32 "php_admin_value[session.save_path]" = "${varDir}/phpSessions";
37 services.postgresql.ensureDatabases = [ "nextcloud" ];
38 services.postgresql.ensureUsers = [
39 { name = "nextcloud"; ensurePermissions = { "DATABASE nextcloud" = "ALL PRIVILEGES"; }; }
41 services.websites.env.production.modules = [ "proxy_fcgi" ];
43 services.websites.env.production.vhostConfs.cloud = {
44 certName = "quatresaisons";
46 hosts = ["nextcloud.4c.salle-s.org" ];
51 SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1
52 <Directory ${nextcloud}>
54 DirectoryIndex index.php
55 Options FollowSymlinks
59 <IfModule mod_headers.c>
60 Header always set Strict-Transport-Security "max-age=15552000; includeSubDomains; preload"
64 SetHandler "proxy:unix:${config.services.phpfpm.pools.nextcloud.socket}|fcgi://localhost"
71 services.websites.env.production.vhostConfs.cloud_wait = let
72 content = pkgs.writeText "contenu" ''
73 nextcloud est un service qui a besoin de pérennité du nom
74 "nextcloud.salle-s.org", on va peut-etre y arriver, c'est une
75 question de jours, voir le message informatique.internet:8017
78 certName = "quatresaisons";
80 hosts = ["nextcloud.salle-s.org" ];
90 users.users.root.packages = let
91 occ = pkgs.writeScriptBin "nextcloud-occ" ''
92 #! ${pkgs.stdenv.shell}
94 NEXTCLOUD_CONFIG_DIR="${nextcloud}/config" \
96 sudo -E -u wwwrun ${phpPackage}/bin/php \
97 -c ${phpPackage}/etc/php.ini \
102 system.activationScripts.nextcloud = {
105 confs = lib.attrsets.mapAttrs (n: v: pkgs.writeText "${n}.json" (builtins.toJSON v)) nextcloud.otherConfig;
108 install -m 0755 -o wwwrun -g wwwrun -d ${varDir}
109 install -m 0755 -o wwwrun -g wwwrun -d ${varDir}/config
110 install -m 0750 -o wwwrun -g wwwrun -d ${varDir}/phpSessions
111 ${builtins.concatStringsSep "\n" (lib.attrsets.mapAttrsToList (n: v:
112 "install -D -m 0644 -o wwwrun -g wwwrun -T ${v} ${varDir}/config/${n}.json"
116 services.phpfpm.pools.nextcloud = {
119 settings = phpFpm.pool;
126 script = pkgs.writeScriptBin "nextcloud-cron" ''
127 #! ${pkgs.stdenv.shell}
128 export LOCALE_ARCHIVE=/run/current-system/sw/lib/locale/locale-archive
129 export PATH=/run/wrappers/bin:$PATH
130 ${phpPackage}/bin/php -d memory_limit=512M -f ${nextcloud}/cron.php
134 */15 * * * * wwwrun ${script}/bin/nextcloud-cron