diff options
author | Ismaël Bouya <ismael.bouya@normalesup.org> | 2019-05-05 19:06:39 +0200 |
---|---|---|
committer | Ismaël Bouya <ismael.bouya@normalesup.org> | 2019-05-05 19:06:39 +0200 |
commit | 0ede7366409e14482017f70f1efc53426279b8d0 (patch) | |
tree | 66530ab7f317238c97169e3bdc5a85c88acc0ec0 /nixops/modules/websites/tools/cloud | |
parent | 9c5fe7b7064afb70dd0b8eb78af745eff84bb2e5 (diff) | |
download | Nix-0ede7366409e14482017f70f1efc53426279b8d0.tar.gz Nix-0ede7366409e14482017f70f1efc53426279b8d0.tar.zst Nix-0ede7366409e14482017f70f1efc53426279b8d0.zip |
Move nextcloud and apps to pkgs
Diffstat (limited to 'nixops/modules/websites/tools/cloud')
-rw-r--r-- | nixops/modules/websites/tools/cloud/default.nix | 151 | ||||
-rw-r--r-- | nixops/modules/websites/tools/cloud/nextcloud.nix | 276 |
2 files changed, 136 insertions, 291 deletions
diff --git a/nixops/modules/websites/tools/cloud/default.nix b/nixops/modules/websites/tools/cloud/default.nix index 5c3e9a8..f7d25cf 100644 --- a/nixops/modules/websites/tools/cloud/default.nix +++ b/nixops/modules/websites/tools/cloud/default.nix | |||
@@ -1,10 +1,48 @@ | |||
1 | { lib, pkgs, config, myconfig, mylibs, ... }: | 1 | { lib, pkgs, config, myconfig, mylibs, ... }: |
2 | let | 2 | let |
3 | nextcloud = pkgs.callPackage ./nextcloud.nix { | 3 | nextcloud = pkgs.webapps.nextcloud.withApps (builtins.attrValues pkgs.webapps.nextcloud-apps); |
4 | env = myconfig.env.tools.nextcloud; | 4 | env = myconfig.env.tools.nextcloud; |
5 | }; | 5 | varDir = "/var/lib/nextcloud"; |
6 | webappName = "tools_nextcloud"; | ||
7 | apacheRoot = "/run/current-system/webapps/${webappName}"; | ||
8 | cfg = config.services.myWebsites.tools.cloud; | ||
9 | phpFpm = rec { | ||
10 | basedir = builtins.concatStringsSep ":" ( | ||
11 | [ nextcloud varDir ] | ||
12 | ++ builtins.attrValues pkgs.webapps.nextcloud-apps); | ||
13 | socket = "/var/run/phpfpm/nextcloud.sock"; | ||
14 | phpConfig = '' | ||
15 | extension=${pkgs.phpPackages.redis}/lib/php/extensions/redis.so | ||
16 | extension=${pkgs.phpPackages.apcu}/lib/php/extensions/apcu.so | ||
17 | zend_extension=${pkgs.php}/lib/php/extensions/opcache.so | ||
18 | ''; | ||
19 | pool = '' | ||
20 | listen = ${socket} | ||
21 | user = wwwrun | ||
22 | group = wwwrun | ||
23 | listen.owner = wwwrun | ||
24 | listen.group = wwwrun | ||
25 | pm = ondemand | ||
26 | pm.max_children = 60 | ||
27 | pm.process_idle_timeout = 60 | ||
28 | |||
29 | php_admin_value[output_buffering] = 0 | ||
30 | php_admin_value[max_execution_time] = 1800 | ||
31 | php_admin_value[zend_extension] = "opcache" | ||
32 | ;already enabled by default? | ||
33 | ;php_value[opcache.enable] = 1 | ||
34 | php_value[opcache.enable_cli] = 1 | ||
35 | php_value[opcache.interned_strings_buffer] = 8 | ||
36 | php_value[opcache.max_accelerated_files] = 10000 | ||
37 | php_value[opcache.memory_consumption] = 128 | ||
38 | php_value[opcache.save_comments] = 1 | ||
39 | php_value[opcache.revalidate_freq] = 1 | ||
40 | php_admin_value[memory_limit] = 512M | ||
6 | 41 | ||
7 | cfg = config.services.myWebsites.tools.cloud; | 42 | php_admin_value[open_basedir] = "/run/wrappers/bin/sendmail:${basedir}:/proc/meminfo:/dev/urandom:/proc/self/fd:/tmp" |
43 | php_admin_value[session.save_path] = "${varDir}/phpSessions" | ||
44 | ''; | ||
45 | }; | ||
8 | in { | 46 | in { |
9 | options.services.myWebsites.tools.cloud = { | 47 | options.services.myWebsites.tools.cloud = { |
10 | enable = lib.mkEnableOption "enable cloud website"; | 48 | enable = lib.mkEnableOption "enable cloud website"; |
@@ -13,23 +51,98 @@ in { | |||
13 | config = lib.mkIf cfg.enable { | 51 | config = lib.mkIf cfg.enable { |
14 | security.acme.certs."eldiron".extraDomains."cloud.immae.eu" = null; | 52 | security.acme.certs."eldiron".extraDomains."cloud.immae.eu" = null; |
15 | 53 | ||
16 | services.myWebsites.tools.modules = nextcloud.apache.modules; | 54 | services.myWebsites.tools.modules = [ "proxy_fcgi" ]; |
17 | 55 | ||
18 | services.myWebsites.tools.vhostConfs.cloud = { | 56 | services.myWebsites.tools.vhostConfs.cloud = { |
19 | certName = "eldiron"; | 57 | certName = "eldiron"; |
20 | hosts = ["cloud.immae.eu" ]; | 58 | hosts = ["cloud.immae.eu" ]; |
21 | root = nextcloud.apache.root; | 59 | root = apacheRoot; |
22 | extraConfig = [ | 60 | extraConfig = [ |
23 | nextcloud.apache.vhostConf | 61 | '' |
62 | SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1 | ||
63 | <Directory ${apacheRoot}> | ||
64 | AcceptPathInfo On | ||
65 | DirectoryIndex index.php | ||
66 | Options FollowSymlinks | ||
67 | Require all granted | ||
68 | AllowOverride all | ||
69 | |||
70 | <IfModule mod_headers.c> | ||
71 | Header always set Strict-Transport-Security "max-age=15552000; includeSubDomains; preload" | ||
72 | </IfModule> | ||
73 | <FilesMatch "\.php$"> | ||
74 | CGIPassAuth on | ||
75 | SetHandler "proxy:unix:${phpFpm.socket}|fcgi://localhost" | ||
76 | </FilesMatch> | ||
77 | |||
78 | </Directory> | ||
79 | '' | ||
24 | ]; | 80 | ]; |
25 | }; | 81 | }; |
26 | 82 | ||
27 | mySecrets.keys = nextcloud.keys; | 83 | mySecrets.keys = [{ |
84 | dest = "webapps/tools-nextcloud"; | ||
85 | user = "wwwrun"; | ||
86 | group = "wwwrun"; | ||
87 | permissions = "0600"; | ||
88 | text = '' | ||
89 | <?php | ||
90 | $CONFIG = array ( | ||
91 | // FIXME: change this value when nextcloud starts getting slow | ||
92 | 'instanceid' => '${env.instance_id}1', | ||
93 | 'datadirectory' => '/var/lib/nextcloud/', | ||
94 | 'passwordsalt' => '${env.password_salt}', | ||
95 | 'debug' => false, | ||
96 | 'dbtype' => 'pgsql', | ||
97 | 'version' => '15.0.4.0', | ||
98 | 'dbname' => '${env.postgresql.database}', | ||
99 | 'dbhost' => '${env.postgresql.socket}', | ||
100 | 'dbtableprefix' => 'oc_', | ||
101 | 'dbuser' => '${env.postgresql.user}', | ||
102 | 'dbpassword' => '${env.postgresql.password}', | ||
103 | 'installed' => true, | ||
104 | 'maxZipInputSize' => 0, | ||
105 | 'allowZipDownload' => true, | ||
106 | 'forcessl' => true, | ||
107 | 'theme' => ${"''"}, | ||
108 | 'maintenance' => false, | ||
109 | 'trusted_domains' => | ||
110 | array ( | ||
111 | 0 => 'cloud.immae.eu', | ||
112 | ), | ||
113 | 'secret' => '${env.secret}', | ||
114 | 'appstoreenabled' => false, | ||
115 | 'appstore.experimental.enabled' => true, | ||
116 | 'loglevel' => 2, | ||
117 | 'trashbin_retention_obligation' => 'auto', | ||
118 | 'htaccess.RewriteBase' => '/', | ||
119 | 'mail_smtpmode' => 'sendmail', | ||
120 | 'mail_smtphost' => '127.0.0.1', | ||
121 | 'mail_smtpname' => ''', | ||
122 | 'mail_smtppassword' => ''', | ||
123 | 'mail_from_address' => 'nextcloud', | ||
124 | 'mail_smtpauth' => false, | ||
125 | 'mail_domain' => 'tools.immae.eu', | ||
126 | 'memcache.local' => '\\OC\\Memcache\\APCu', | ||
127 | 'memcache.locking' => '\\OC\\Memcache\\Redis', | ||
128 | 'filelocking.enabled' => true, | ||
129 | 'redis' => | ||
130 | array ( | ||
131 | 'host' => '${env.redis.socket}', | ||
132 | 'port' => 0, | ||
133 | 'dbindex' => ${env.redis.db_index}, | ||
134 | ), | ||
135 | 'overwrite.cli.url' => 'https://cloud.immae.eu', | ||
136 | 'ldapIgnoreNamingRules' => false, | ||
137 | 'ldapProviderFactory' => '\\OCA\\User_LDAP\\LDAPProviderFactory', | ||
138 | ); | ||
139 | ''; | ||
140 | }]; | ||
28 | users.users.root.packages = let | 141 | users.users.root.packages = let |
29 | occ = pkgs.writeScriptBin "nextcloud-occ" '' | 142 | occ = pkgs.writeScriptBin "nextcloud-occ" '' |
30 | #! ${pkgs.stdenv.shell} | 143 | #! ${pkgs.stdenv.shell} |
31 | cd ${nextcloud.webRoot} | 144 | cd ${nextcloud} |
32 | NEXTCLOUD_CONFIG_DIR="${nextcloud.webRoot}/config" \ | 145 | NEXTCLOUD_CONFIG_DIR="${nextcloud}/config" \ |
33 | exec \ | 146 | exec \ |
34 | sudo -u wwwrun ${pkgs.php}/bin/php \ | 147 | sudo -u wwwrun ${pkgs.php}/bin/php \ |
35 | -c ${pkgs.php}/etc/php.ini \ | 148 | -c ${pkgs.php}/etc/php.ini \ |
@@ -37,15 +150,23 @@ in { | |||
37 | ''; | 150 | ''; |
38 | in [ occ ]; | 151 | in [ occ ]; |
39 | 152 | ||
40 | system.activationScripts.nextcloud = nextcloud.activationScript; | 153 | system.activationScripts.nextcloud = { |
154 | deps = [ ]; | ||
155 | text = '' | ||
156 | install -m 0755 -o wwwrun -g wwwrun -d ${varDir} | ||
157 | install -m 0750 -o wwwrun -g wwwrun -d ${varDir}/phpSessions | ||
158 | install -D -m 0644 -o wwwrun -g wwwrun ${./nextcloud-config}/* -t ${varDir}/config | ||
159 | install -D -m 0600 -o wwwrun -g wwwrun -T /var/secrets/webapps/tools-nextcloud ${varDir}/config/config.php | ||
160 | ''; | ||
161 | }; | ||
41 | system.extraSystemBuilderCmds = '' | 162 | system.extraSystemBuilderCmds = '' |
42 | mkdir -p $out/webapps | 163 | mkdir -p $out/webapps |
43 | ln -s ${nextcloud.webRoot} $out/webapps/${nextcloud.apache.webappName} | 164 | ln -s ${nextcloud} $out/webapps/${webappName} |
44 | ''; | 165 | ''; |
45 | 166 | ||
46 | services.myPhpfpm = { | 167 | services.myPhpfpm = { |
47 | poolPhpConfigs.nextcloud = nextcloud.phpFpm.phpConfig; | 168 | poolPhpConfigs.nextcloud = phpFpm.phpConfig; |
48 | poolConfigs.nextcloud = nextcloud.phpFpm.pool; | 169 | poolConfigs.nextcloud = phpFpm.pool; |
49 | }; | 170 | }; |
50 | 171 | ||
51 | services.cron = { | 172 | services.cron = { |
@@ -53,7 +174,7 @@ in { | |||
53 | systemCronJobs = [ | 174 | systemCronJobs = [ |
54 | '' | 175 | '' |
55 | LOCALE_ARCHIVE=/run/current-system/sw/lib/locale/locale-archive | 176 | LOCALE_ARCHIVE=/run/current-system/sw/lib/locale/locale-archive |
56 | */15 * * * * wwwrun ${pkgs.php}/bin/php -f ${nextcloud.webRoot}/cron.php | 177 | */15 * * * * wwwrun ${pkgs.php}/bin/php -f ${nextcloud}/cron.php |
57 | '' | 178 | '' |
58 | ]; | 179 | ]; |
59 | }; | 180 | }; |
diff --git a/nixops/modules/websites/tools/cloud/nextcloud.nix b/nixops/modules/websites/tools/cloud/nextcloud.nix deleted file mode 100644 index b62606f..0000000 --- a/nixops/modules/websites/tools/cloud/nextcloud.nix +++ /dev/null | |||
@@ -1,276 +0,0 @@ | |||
1 | { stdenv, fetchurl, env, writeText, lib, phpPackages, php }: | ||
2 | let | ||
3 | nextcloud = let | ||
4 | buildApp = { appName, version, url, sha256, installPhase ? "mkdir -p $out && cp -R . $out/" }: | ||
5 | stdenv.mkDerivation rec { | ||
6 | name = "nextcloud-app-${appName}-${version}"; | ||
7 | inherit version; | ||
8 | phases = "unpackPhase installPhase"; | ||
9 | inherit installPhase; | ||
10 | src = fetchurl { inherit url sha256; }; | ||
11 | }; | ||
12 | apps = { | ||
13 | audioplayer = buildApp rec { | ||
14 | appName = "audioplayer"; | ||
15 | version = "2.6.0"; | ||
16 | url = "https://github.com/Rello/${appName}/releases/download/${version}/${appName}-${version}.tar.gz"; | ||
17 | sha256 = "08apm7dhnljagcvq8b1dsqcck4nqwmz60bf3mx44xvbhiaq6nim4"; | ||
18 | }; | ||
19 | bookmarks = buildApp rec { | ||
20 | appName = "bookmarks"; | ||
21 | version = "0.16.2"; | ||
22 | url = "https://github.com/nextcloud/${appName}/releases/download/v${version}/${appName}-${version}.tar.gz"; | ||
23 | sha256 = "0ghk71iyk5xlqsfahg0d0lpp9lparpdnv2qx11a7j64pc9gzcfl4"; | ||
24 | }; | ||
25 | calendar = buildApp rec { | ||
26 | appName = "calendar"; | ||
27 | version = "1.6.4"; | ||
28 | url = "https://github.com/nextcloud/${appName}/releases/download/v${version}/${appName}.tar.gz"; | ||
29 | sha256 = "00dijvcvy7snsjslfbyzvpp9anhms22zp1f0zkj89ln33jmana63"; | ||
30 | }; | ||
31 | contacts = buildApp rec { | ||
32 | appName = "contacts"; | ||
33 | version = "3.0.3"; | ||
34 | url = "https://github.com/nextcloud/${appName}/releases/download/v${version}/${appName}.tar.gz"; | ||
35 | sha256 = "026hfigfzqb1cvq6a7mg9656nkm21c19a6ipqzgv00ycf38qyk95"; | ||
36 | }; | ||
37 | deck = buildApp rec { | ||
38 | appName = "deck"; | ||
39 | version = "0.5.2"; | ||
40 | url = "https://github.com/nextcloud/${appName}/releases/download/v${version}/${appName}.tar.gz"; | ||
41 | sha256 = "1kygzixxdkp3dbma009p3pw0fj8wgcqcv39n7pay78lh6zi3nic7"; | ||
42 | }; | ||
43 | files_markdown = buildApp rec { | ||
44 | appName = "files_markdown"; | ||
45 | version = "2.0.5"; | ||
46 | url = "https://github.com/icewind1991/${appName}/releases/download/v${version}/${appName}.tar.gz"; | ||
47 | sha256 = "1dzvy4c6vff2qmkwqw13dx92xdkafaxgnipswjw44mh0ncc2n9ym"; | ||
48 | }; | ||
49 | gpxedit = buildApp rec { | ||
50 | appName = "gpxedit"; | ||
51 | version = "0.0.10"; | ||
52 | url = "https://gitlab.com/eneiluj/gpxedit-oc/wikis/uploads/33d187268c5f6f6a55350d656305701c/${appName}-${version}.tar.gz"; | ||
53 | sha256 = "0ynpaxm0xhvcj8xax6rm1w0p6j57wbqidhi7bhn268n483gwl2sw"; | ||
54 | }; | ||
55 | gpxpod = buildApp rec { | ||
56 | appName = "gpxpod"; | ||
57 | version = "3.0.1"; | ||
58 | url = "https://gitlab.com/eneiluj/gpxpod-oc/wikis/uploads/3f5fbc895de15f11f90582c4872839dc/${appName}-${version}.tar.gz"; | ||
59 | sha256 = "1g3602phrdpybamr4bnk5niv1znmwp19lqyw6d8yxmc84lg99dny"; | ||
60 | }; | ||
61 | keeweb = buildApp rec { | ||
62 | appName = "keeweb"; | ||
63 | version = "0.4.0"; | ||
64 | url = "https://github.com/jhass/nextcloud-keeweb/releases/download/v${version}/${appName}-${version}.tar.gz"; | ||
65 | sha256 = "0453kkb0a8vfivmibpwpx4bvhyn64jhns6cdfjacmnvbm6d75nj1"; | ||
66 | installPhase = '' | ||
67 | mkdir -p $out | ||
68 | cp -R . $out/ | ||
69 | sed -i -e 's/max-version="12"/max-version="16"/' $out/appinfo/info.xml | ||
70 | ''; | ||
71 | }; | ||
72 | music = buildApp rec { | ||
73 | appName = "music"; | ||
74 | version = "0.9.3"; | ||
75 | url = "https://github.com/owncloud/${appName}/archive/v${version}.tar.gz"; | ||
76 | sha256 = "1x4c2v8hnm9yi3fzjglfwd2brzn99v8zavgfczc5jfj30v3n555z"; | ||
77 | }; | ||
78 | notes = buildApp rec { | ||
79 | appName = "notes"; | ||
80 | version = "2.5.1"; | ||
81 | url = "https://github.com/nextcloud/${appName}/releases/download/v${version}/${appName}.tar.gz"; | ||
82 | sha256 = "1albzqqsdirzyw8vhvs7r0qm2wqp8vm9vmxm4crhncd85bk01hmh"; | ||
83 | }; | ||
84 | ocsms = buildApp rec { | ||
85 | appName = "ocsms"; | ||
86 | version = "2.1.1"; | ||
87 | url = "https://github.com/nextcloud/${appName}/releases/download/${version}/${appName}-${version}.tar.gz"; | ||
88 | sha256 = "0sgfbmy1c8rgzjvf9snc7rzgp8aqsc65zfwgi6qcsf2g6gam5n7a"; | ||
89 | installPhase = '' | ||
90 | sed -i -e "/addScript.*devel/d" -e "s@//\(.*addScript.*app.min\)@\1@" templates/main.php | ||
91 | mkdir -p $out | ||
92 | cp -R . $out/ | ||
93 | ''; | ||
94 | }; | ||
95 | passman = buildApp rec { | ||
96 | appName = "passman"; | ||
97 | version = "2.2.1"; | ||
98 | url = "https://releases.passman.cc/${appName}_${version}.tar.gz"; | ||
99 | sha256 = "064pq9d0pl3y1vcywpi19fg47zy7j4h0jaxy6jklwzwcrmzagbka"; | ||
100 | }; | ||
101 | spreed = buildApp rec { | ||
102 | appName = "spreed"; | ||
103 | version = "5.0.2"; | ||
104 | url = "https://github.com/nextcloud/${appName}/releases/download/v${version}/${appName}-${version}.tar.gz"; | ||
105 | sha256 = "0z9zhpkq485lhwirc2f04427rd47hzv0r8frz72dkrszb037qjvv"; | ||
106 | }; | ||
107 | tasks = buildApp rec { | ||
108 | appName = "tasks"; | ||
109 | version = "0.9.8"; | ||
110 | url = "https://github.com/nextcloud/${appName}/releases/download/v${version}/${appName}.tar.gz"; | ||
111 | sha256 = "089m124lfsfk09fqj50x9n7zndq97jp5afgb8s001rpmzym4g6ny"; | ||
112 | }; | ||
113 | }; | ||
114 | in rec { | ||
115 | varDir = "/var/lib/nextcloud"; | ||
116 | keys = [{ | ||
117 | dest = "webapps/tools-nextcloud"; | ||
118 | user = apache.user; | ||
119 | group = apache.group; | ||
120 | permissions = "0600"; | ||
121 | text = '' | ||
122 | <?php | ||
123 | $CONFIG = array ( | ||
124 | // FIXME: change this value when nextcloud starts getting slow | ||
125 | 'instanceid' => '${env.instance_id}1', | ||
126 | 'datadirectory' => '/var/lib/nextcloud/', | ||
127 | 'passwordsalt' => '${env.password_salt}', | ||
128 | 'debug' => false, | ||
129 | 'dbtype' => 'pgsql', | ||
130 | 'version' => '15.0.4.0', | ||
131 | 'dbname' => '${env.postgresql.database}', | ||
132 | 'dbhost' => '${env.postgresql.socket}', | ||
133 | 'dbtableprefix' => 'oc_', | ||
134 | 'dbuser' => '${env.postgresql.user}', | ||
135 | 'dbpassword' => '${env.postgresql.password}', | ||
136 | 'installed' => true, | ||
137 | 'maxZipInputSize' => 0, | ||
138 | 'allowZipDownload' => true, | ||
139 | 'forcessl' => true, | ||
140 | 'theme' => ${"''"}, | ||
141 | 'maintenance' => false, | ||
142 | 'trusted_domains' => | ||
143 | array ( | ||
144 | 0 => 'cloud.immae.eu', | ||
145 | ), | ||
146 | 'secret' => '${env.secret}', | ||
147 | 'appstoreenabled' => false, | ||
148 | 'appstore.experimental.enabled' => true, | ||
149 | 'loglevel' => 2, | ||
150 | 'trashbin_retention_obligation' => 'auto', | ||
151 | 'htaccess.RewriteBase' => '/', | ||
152 | 'mail_smtpmode' => 'sendmail', | ||
153 | 'mail_smtphost' => '127.0.0.1', | ||
154 | 'mail_smtpname' => ''', | ||
155 | 'mail_smtppassword' => ''', | ||
156 | 'mail_from_address' => 'nextcloud', | ||
157 | 'mail_smtpauth' => false, | ||
158 | 'mail_domain' => 'tools.immae.eu', | ||
159 | 'memcache.local' => '\\OC\\Memcache\\APCu', | ||
160 | 'memcache.locking' => '\\OC\\Memcache\\Redis', | ||
161 | 'filelocking.enabled' => true, | ||
162 | 'redis' => | ||
163 | array ( | ||
164 | 'host' => '${env.redis.socket}', | ||
165 | 'port' => 0, | ||
166 | 'dbindex' => ${env.redis.db_index}, | ||
167 | ), | ||
168 | 'overwrite.cli.url' => 'https://cloud.immae.eu', | ||
169 | 'ldapIgnoreNamingRules' => false, | ||
170 | 'ldapProviderFactory' => '\\OCA\\User_LDAP\\LDAPProviderFactory', | ||
171 | ); | ||
172 | ''; | ||
173 | }]; | ||
174 | webRoot = stdenv.mkDerivation rec { | ||
175 | name = "nextcloud-${version}"; | ||
176 | version = "15.0.4"; | ||
177 | |||
178 | src = fetchurl { | ||
179 | url = "https://download.nextcloud.com/server/releases/${name}.tar.bz2"; | ||
180 | sha256 = "0xwg7p31y1pkjk1pzygh9shpqxnfkafrab52j7in7xblq53v0zgq"; | ||
181 | }; | ||
182 | |||
183 | installPhase = '' | ||
184 | mkdir -p $out/ | ||
185 | cp -R . $out/ | ||
186 | rm -r $out/config | ||
187 | ln -sf ${varDir}/config $out/config | ||
188 | ${builtins.concatStringsSep "\n" ( | ||
189 | lib.attrsets.mapAttrsToList (name: value: "ln -sf ${value} $out/apps/${name}") apps | ||
190 | )} | ||
191 | ''; | ||
192 | |||
193 | meta = { | ||
194 | description = "Sharing solution for files, calendars, contacts and more"; | ||
195 | homepage = https://nextcloud.com; | ||
196 | maintainers = with lib.maintainers; [ schneefux bachp globin fpletz ]; | ||
197 | license = lib.licenses.agpl3Plus; | ||
198 | platforms = with lib.platforms; unix; | ||
199 | }; | ||
200 | }; | ||
201 | activationScript = { | ||
202 | deps = [ ]; | ||
203 | text = '' | ||
204 | install -m 0755 -o ${apache.user} -g ${apache.group} -d ${varDir} | ||
205 | install -m 0750 -o ${apache.user} -g ${apache.group} -d ${varDir}/phpSessions | ||
206 | install -D -m 0644 -o ${apache.user} -g ${apache.group} ${./nextcloud-config}/* -t ${varDir}/config | ||
207 | install -D -m 0600 -o ${apache.user} -g ${apache.group} -T /var/secrets/webapps/tools-nextcloud ${varDir}/config/config.php | ||
208 | ''; | ||
209 | }; | ||
210 | apache = rec { | ||
211 | user = "wwwrun"; | ||
212 | group = "wwwrun"; | ||
213 | modules = [ "proxy_fcgi" ]; | ||
214 | webappName = "tools_nextcloud"; | ||
215 | root = "/run/current-system/webapps/${webappName}"; | ||
216 | vhostConf = '' | ||
217 | SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1 | ||
218 | <Directory ${root}> | ||
219 | AcceptPathInfo On | ||
220 | DirectoryIndex index.php | ||
221 | Options FollowSymlinks | ||
222 | Require all granted | ||
223 | AllowOverride all | ||
224 | |||
225 | <IfModule mod_headers.c> | ||
226 | Header always set Strict-Transport-Security "max-age=15552000; includeSubDomains; preload" | ||
227 | </IfModule> | ||
228 | <FilesMatch "\.php$"> | ||
229 | CGIPassAuth on | ||
230 | SetHandler "proxy:unix:${phpFpm.socket}|fcgi://localhost" | ||
231 | </FilesMatch> | ||
232 | |||
233 | </Directory> | ||
234 | |||
235 | ''; | ||
236 | }; | ||
237 | phpFpm = rec { | ||
238 | basedir = builtins.concatStringsSep ":" ( | ||
239 | [ webRoot varDir ] | ||
240 | ++ lib.attrsets.mapAttrsToList (name: value: value) apps); | ||
241 | socket = "/var/run/phpfpm/nextcloud.sock"; | ||
242 | phpConfig = '' | ||
243 | extension=${phpPackages.redis}/lib/php/extensions/redis.so | ||
244 | extension=${phpPackages.apcu}/lib/php/extensions/apcu.so | ||
245 | zend_extension=${php}/lib/php/extensions/opcache.so | ||
246 | ''; | ||
247 | pool = '' | ||
248 | listen = ${socket} | ||
249 | user = ${apache.user} | ||
250 | group = ${apache.group} | ||
251 | listen.owner = ${apache.user} | ||
252 | listen.group = ${apache.group} | ||
253 | pm = ondemand | ||
254 | pm.max_children = 60 | ||
255 | pm.process_idle_timeout = 60 | ||
256 | |||
257 | php_admin_value[output_buffering] = 0 | ||
258 | php_admin_value[max_execution_time] = 1800 | ||
259 | php_admin_value[zend_extension] = "opcache" | ||
260 | ;already enabled by default? | ||
261 | ;php_value[opcache.enable] = 1 | ||
262 | php_value[opcache.enable_cli] = 1 | ||
263 | php_value[opcache.interned_strings_buffer] = 8 | ||
264 | php_value[opcache.max_accelerated_files] = 10000 | ||
265 | php_value[opcache.memory_consumption] = 128 | ||
266 | php_value[opcache.save_comments] = 1 | ||
267 | php_value[opcache.revalidate_freq] = 1 | ||
268 | php_admin_value[memory_limit] = 512M | ||
269 | |||
270 | php_admin_value[open_basedir] = "/run/wrappers/bin/sendmail:${basedir}:/proc/meminfo:/dev/urandom:/proc/self/fd:/tmp" | ||
271 | php_admin_value[session.save_path] = "${varDir}/phpSessions" | ||
272 | ''; | ||
273 | }; | ||
274 | }; | ||
275 | in | ||
276 | nextcloud | ||