1 { stdenv, fetchurl, env, writeText, lib, phpPackages, php }:
4 buildApp = { appName, version, url, sha256, installPhase ? "mkdir -p $out && cp -R . $out/" }:
5 stdenv.mkDerivation rec {
6 name = "nextcloud-app-${appName}-${version}";
8 phases = "unpackPhase installPhase";
10 src = fetchurl { inherit url sha256; };
13 audioplayer = buildApp rec {
14 appName = "audioplayer";
16 url = "https://github.com/Rello/${appName}/releases/download/${version}/${appName}-${version}.tar.gz";
17 sha256 = "08apm7dhnljagcvq8b1dsqcck4nqwmz60bf3mx44xvbhiaq6nim4";
19 bookmarks = buildApp rec {
20 appName = "bookmarks";
22 url = "https://github.com/nextcloud/${appName}/releases/download/v${version}/${appName}-${version}.tar.gz";
23 sha256 = "0ghk71iyk5xlqsfahg0d0lpp9lparpdnv2qx11a7j64pc9gzcfl4";
25 calendar = buildApp rec {
28 url = "https://github.com/nextcloud/${appName}/releases/download/v${version}/${appName}.tar.gz";
29 sha256 = "00dijvcvy7snsjslfbyzvpp9anhms22zp1f0zkj89ln33jmana63";
31 contacts = buildApp rec {
34 url = "https://github.com/nextcloud/${appName}/releases/download/v${version}/${appName}.tar.gz";
35 sha256 = "026hfigfzqb1cvq6a7mg9656nkm21c19a6ipqzgv00ycf38qyk95";
40 url = "https://github.com/nextcloud/${appName}/releases/download/v${version}/${appName}.tar.gz";
41 sha256 = "1kygzixxdkp3dbma009p3pw0fj8wgcqcv39n7pay78lh6zi3nic7";
43 files_markdown = buildApp rec {
44 appName = "files_markdown";
46 url = "https://github.com/icewind1991/${appName}/releases/download/v${version}/${appName}.tar.gz";
47 sha256 = "1dzvy4c6vff2qmkwqw13dx92xdkafaxgnipswjw44mh0ncc2n9ym";
49 gpxedit = buildApp rec {
52 url = "https://gitlab.com/eneiluj/gpxedit-oc/wikis/uploads/33d187268c5f6f6a55350d656305701c/${appName}-${version}.tar.gz";
53 sha256 = "0ynpaxm0xhvcj8xax6rm1w0p6j57wbqidhi7bhn268n483gwl2sw";
55 gpxpod = buildApp rec {
58 url = "https://gitlab.com/eneiluj/gpxpod-oc/wikis/uploads/3f5fbc895de15f11f90582c4872839dc/${appName}-${version}.tar.gz";
59 sha256 = "1g3602phrdpybamr4bnk5niv1znmwp19lqyw6d8yxmc84lg99dny";
61 keeweb = buildApp rec {
64 url = "https://github.com/jhass/nextcloud-keeweb/releases/download/v${version}/${appName}-${version}.tar.gz";
65 sha256 = "0453kkb0a8vfivmibpwpx4bvhyn64jhns6cdfjacmnvbm6d75nj1";
69 sed -i -e 's/max-version="12"/max-version="16"/' $out/appinfo/info.xml
72 music = buildApp rec {
75 url = "https://github.com/owncloud/${appName}/archive/v${version}.tar.gz";
76 sha256 = "1x4c2v8hnm9yi3fzjglfwd2brzn99v8zavgfczc5jfj30v3n555z";
78 notes = buildApp rec {
81 url = "https://github.com/nextcloud/${appName}/releases/download/v${version}/${appName}.tar.gz";
82 sha256 = "1albzqqsdirzyw8vhvs7r0qm2wqp8vm9vmxm4crhncd85bk01hmh";
84 ocsms = buildApp rec {
87 url = "https://github.com/nextcloud/${appName}/releases/download/${version}/${appName}-${version}.tar.gz";
88 sha256 = "0sgfbmy1c8rgzjvf9snc7rzgp8aqsc65zfwgi6qcsf2g6gam5n7a";
90 sed -i -e "/addScript.*devel/d" -e "s@//\(.*addScript.*app.min\)@\1@" templates/main.php
95 passman = buildApp rec {
98 url = "https://releases.passman.cc/${appName}_${version}.tar.gz";
99 sha256 = "064pq9d0pl3y1vcywpi19fg47zy7j4h0jaxy6jklwzwcrmzagbka";
101 spreed = buildApp rec {
104 url = "https://github.com/nextcloud/${appName}/releases/download/v${version}/${appName}-${version}.tar.gz";
105 sha256 = "0z9zhpkq485lhwirc2f04427rd47hzv0r8frz72dkrszb037qjvv";
107 tasks = buildApp rec {
110 url = "https://github.com/nextcloud/${appName}/releases/download/v${version}/${appName}.tar.gz";
111 sha256 = "089m124lfsfk09fqj50x9n7zndq97jp5afgb8s001rpmzym4g6ny";
115 varDir = "/var/lib/nextcloud";
117 dest = "webapps/tools-nextcloud";
119 group = apache.group;
120 permissions = "0600";
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}',
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}',
137 'maxZipInputSize' => 0,
138 'allowZipDownload' => true,
141 'maintenance' => false,
144 0 => 'cloud.immae.eu',
146 'secret' => '${env.secret}',
147 'appstoreenabled' => false,
148 'appstore.experimental.enabled' => true,
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,
164 'host' => '${env.redis.socket}',
166 'dbindex' => ${env.redis.db_index},
168 'overwrite.cli.url' => 'https://cloud.immae.eu',
169 'ldapIgnoreNamingRules' => false,
170 'ldapProviderFactory' => '\\OCA\\User_LDAP\\LDAPProviderFactory',
174 webRoot = stdenv.mkDerivation rec {
175 name = "nextcloud-${version}";
179 url = "https://download.nextcloud.com/server/releases/${name}.tar.bz2";
180 sha256 = "0xwg7p31y1pkjk1pzygh9shpqxnfkafrab52j7in7xblq53v0zgq";
187 ln -sf ${varDir}/config $out/config
188 ${builtins.concatStringsSep "\n" (
189 lib.attrsets.mapAttrsToList (name: value: "ln -sf ${value} $out/apps/${name}") apps
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;
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
213 modules = [ "proxy_fcgi" ];
214 webappName = "tools_nextcloud";
215 root = "/run/current-system/webapps/${webappName}";
217 SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1
220 DirectoryIndex index.php
221 Options FollowSymlinks
225 <IfModule mod_headers.c>
226 Header always set Strict-Transport-Security "max-age=15552000; includeSubDomains; preload"
228 <FilesMatch "\.php$">
230 SetHandler "proxy:unix:${phpFpm.socket}|fcgi://localhost"
238 basedir = builtins.concatStringsSep ":" (
240 ++ lib.attrsets.mapAttrsToList (name: value: value) apps);
241 socket = "/var/run/phpfpm/nextcloud.sock";
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
249 user = ${apache.user}
250 group = ${apache.group}
251 listen.owner = ${apache.user}
252 listen.group = ${apache.group}
255 pm.process_idle_timeout = 60
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
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"