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.start_servers" = "2";
16 "pm.min_spare_servers" = "1";
17 "pm.max_spare_servers" = "3";
18 "pm.max_children" = "60";
19 "pm.process_idle_timeout" = "60";
21 "php_admin_value[output_buffering]" = "0";
22 "php_admin_value[max_execution_time]" = "1800";
23 "php_admin_value[zend_extension]" = "opcache";
24 #already enabled by default?
25 #"php_value[opcache.enable]" = "1";
26 "php_value[opcache.enable_cli]" = "1";
27 "php_value[opcache.interned_strings_buffer]" = "8";
28 "php_value[opcache.max_accelerated_files]" = "10000";
29 "php_value[opcache.memory_consumption]" = "128";
30 "php_value[opcache.save_comments]" = "1";
31 "php_value[opcache.revalidate_freq]" = "1";
32 "php_admin_value[memory_limit]" = "512M";
34 "php_admin_value[open_basedir]" = "/run/wrappers/bin/sendmail:${basedir}:/proc/meminfo:/dev/urandom:/proc/self/fd:/tmp";
35 "php_admin_value[session.save_path]" = "${varDir}/phpSessions";
40 services.postgresql.ensureDatabases = [ "nextcloud" ];
41 services.postgresql.ensureUsers = [
42 { name = "nextcloud"; ensurePermissions = { "DATABASE nextcloud" = "ALL PRIVILEGES"; }; }
44 services.websites.env.production.modules = [ "proxy_fcgi" ];
46 services.websites.env.production.vhostConfs.cloud = {
47 certName = "quatresaisons";
49 hosts = ["nextcloud.4c.salle-s.org" ];
54 SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1
55 <Directory ${nextcloud}>
57 DirectoryIndex index.php
58 Options FollowSymlinks
62 <IfModule mod_headers.c>
63 Header always set Strict-Transport-Security "max-age=15552000; includeSubDomains; preload"
67 SetHandler "proxy:unix:${config.services.phpfpm.pools.nextcloud.socket}|fcgi://localhost"
74 services.websites.env.production.vhostConfs.cloud_wait = let
75 content = pkgs.writeText "contenu" ''
76 nextcloud est un service qui a besoin de pérennité du nom
77 "nextcloud.salle-s.org", on va peut-etre y arriver, c'est une
78 question de jours, voir le message informatique.internet:8017
81 certName = "quatresaisons";
83 hosts = ["nextcloud.salle-s.org" ];
93 users.users.root.packages = let
94 occ = pkgs.writeScriptBin "nextcloud-occ" ''
95 #! ${pkgs.stdenv.shell}
97 NEXTCLOUD_CONFIG_DIR="${nextcloud}/config" \
99 sudo -E -u wwwrun ${phpPackage}/bin/php \
100 -c ${phpPackage}/etc/php.ini \
105 system.activationScripts.nextcloud = {
108 confs = lib.attrsets.mapAttrs (n: v: pkgs.writeText "${n}.json" (builtins.toJSON v)) nextcloud.otherConfig;
111 install -m 0755 -o wwwrun -g wwwrun -d ${varDir}
112 install -m 0755 -o wwwrun -g wwwrun -d ${varDir}/config
113 install -m 0750 -o wwwrun -g wwwrun -d ${varDir}/phpSessions
114 ${builtins.concatStringsSep "\n" (lib.attrsets.mapAttrsToList (n: v:
115 "install -D -m 0644 -o wwwrun -g wwwrun -T ${v} ${varDir}/config/${n}.json"
119 services.phpfpm.pools.nextcloud = {
122 settings = phpFpm.pool;
129 script = pkgs.writeScriptBin "nextcloud-cron" ''
130 #! ${pkgs.stdenv.shell}
131 export LOCALE_ARCHIVE=/run/current-system/sw/lib/locale/locale-archive
132 export PATH=/run/wrappers/bin:$PATH
133 ${phpPackage}/bin/php -d memory_limit=512M -f ${nextcloud}/cron.php
137 */15 * * * * wwwrun ${script}/bin/nextcloud-cron