]>
Commit | Line | Data |
---|---|---|
3a1461cf | 1 | { varDir ? "/var/lib/nextcloud", otherConfig ? {}, lib, stdenv, fetchurl }: |
0ede7366 | 2 | let |
3a1461cf | 3 | buildApp = { appName, version, url, sha256, otherConfig ? {}, installPhase ? "mkdir -p $out && cp -R . $out/" }: |
0ede7366 IB |
4 | stdenv.mkDerivation rec { |
5 | name = "nextcloud-app-${appName}-${version}"; | |
6 | inherit version; | |
7 | phases = "unpackPhase installPhase"; | |
8 | inherit installPhase; | |
9 | src = fetchurl { inherit url sha256; }; | |
3a1461cf IB |
10 | passthru = { |
11 | inherit appName otherConfig; | |
12 | }; | |
0ede7366 IB |
13 | }; |
14 | withApps = apps: package.overrideAttrs(old: { | |
15 | name = "${old.name}-with-apps"; | |
16 | ||
17 | installPhase = old.installPhase + ( | |
18 | builtins.concatStringsSep "\n" ( | |
19 | map (value: "ln -sf ${value} $out/apps/${value.appName}") apps | |
20 | )); | |
3a1461cf IB |
21 | |
22 | passthru.otherConfig = with lib.attrsets; with lib.lists; let | |
23 | zipped = zipAttrs ([old.otherConfig or {}] ++ map (v: v.otherConfig) apps); | |
24 | in | |
25 | { | |
26 | mimetypealiases = foldr (h: prev: prev // h) {} zipped.mimetypealiases; | |
27 | mimetypemapping = mapAttrs (_: v: unique (flatten v)) (zipAttrs zipped.mimetypemapping); | |
28 | }; | |
0ede7366 IB |
29 | passthru.apps = apps; |
30 | passthru.withApps = moreApps: old.withApps (moreApps ++ apps); | |
31 | }); | |
32 | ||
33 | package = stdenv.mkDerivation rec { | |
34 | name = "nextcloud-${version}"; | |
3a1461cf | 35 | version = "16.0.0"; |
0ede7366 IB |
36 | |
37 | src = fetchurl { | |
38 | url = "https://download.nextcloud.com/server/releases/${name}.tar.bz2"; | |
3a1461cf | 39 | sha256 = "0bj014vczlrql1w32pqmr7cyqn9awnyzpi2syxhg16qxic1gfcj5"; |
0ede7366 IB |
40 | }; |
41 | ||
42 | installPhase = '' | |
43 | mkdir -p $out/ | |
44 | cp -R . $out/ | |
45 | rm -r $out/config | |
46 | ln -sf ${varDir}/config $out/config | |
47 | ''; | |
48 | ||
49 | passthru = { | |
50 | apps = []; | |
3a1461cf | 51 | inherit otherConfig buildApp withApps varDir; |
0ede7366 IB |
52 | }; |
53 | meta = { | |
54 | description = "Sharing solution for files, calendars, contacts and more"; | |
55 | homepage = https://nextcloud.com; | |
56 | maintainers = with lib.maintainers; [ schneefux bachp globin fpletz ]; | |
57 | license = lib.licenses.agpl3Plus; | |
58 | platforms = with lib.platforms; unix; | |
59 | }; | |
60 | }; | |
61 | in package |