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