]>
Commit | Line | Data |
---|---|---|
c4216ddb | 1 | { varDir ? "/var/lib/nextcloud", nextcloudVersion ? 18, otherConfig ? {}, lib, stdenv, callPackage, fetchurl }: |
0ede7366 | 2 | let |
65b715d7 IB |
3 | appNames = [ |
4 | "apporder" "audioplayer" "bookmarks" "calendar" "carnet" "contacts" | |
5 | "cookbook" "deck" "extract" "files_markdown" "files_readmemd" | |
6 | "flowupload" "gpxedit" "gpxpod" "keeweb" "maps" "metadata" "music" | |
7 | "notes" "ocsms" "passman" "polls" "spreed" "tasks" | |
8 | ]; | |
9 | allApps = lib.attrsets.genAttrs appNames | |
10 | (name: callPackage (./apps + "/${name}.nix") { inherit buildApp nextcloudVersion; }); | |
3a1461cf | 11 | buildApp = { appName, version, url, sha256, otherConfig ? {}, installPhase ? "mkdir -p $out && cp -R . $out/" }: |
0ede7366 IB |
12 | stdenv.mkDerivation rec { |
13 | name = "nextcloud-app-${appName}-${version}"; | |
14 | inherit version; | |
15 | phases = "unpackPhase installPhase"; | |
16 | inherit installPhase; | |
17 | src = fetchurl { inherit url sha256; }; | |
3a1461cf IB |
18 | passthru = { |
19 | inherit appName otherConfig; | |
20 | }; | |
0ede7366 | 21 | }; |
65b715d7 IB |
22 | toPassthru = pkg: apps: otherConfig: { |
23 | inherit apps otherConfig allApps buildApp varDir; | |
24 | withApps = withApps pkg; | |
25 | }; | |
26 | withApps = pkg: toApps: | |
27 | let | |
28 | apps = toApps allApps; | |
29 | toInstallApp = n: '' | |
30 | ln -sf ${n} $out/apps/${n.appName} | |
31 | ''; | |
32 | zipped = lib.attrsets.zipAttrs ([pkg.otherConfig or {}] ++ map (v: v.otherConfig) apps); | |
33 | appConfigs = with lib.attrsets; with lib.lists; { | |
34 | mimetypealiases = foldr (h: prev: prev // h) {} (zipped.mimetypealiases or []); | |
35 | mimetypemapping = mapAttrs (_: v: unique (flatten v)) (zipAttrs (zipped.mimetypemapping or [])); | |
36 | }; | |
37 | newNextcloud = pkg.overrideAttrs(old: { | |
38 | installPhase = old.installPhase + "\n" + builtins.concatStringsSep "\n" (map toInstallApp apps); | |
39 | passthru = toPassthru newNextcloud (pkg.apps ++ apps) appConfigs; | |
40 | }); | |
41 | in newNextcloud; | |
0ede7366 IB |
42 | package = stdenv.mkDerivation rec { |
43 | name = "nextcloud-${version}"; | |
c4216ddb | 44 | version = "${builtins.toString nextcloudVersion}.0.4"; |
0ede7366 IB |
45 | |
46 | src = fetchurl { | |
47 | url = "https://download.nextcloud.com/server/releases/${name}.tar.bz2"; | |
c4216ddb | 48 | sha256 = "0aa3f4xbkzacfw0h9aic0ywk5mqlwka83qaszizj8lmk68kf3n7s"; |
0ede7366 IB |
49 | }; |
50 | ||
51 | installPhase = '' | |
52 | mkdir -p $out/ | |
53 | cp -R . $out/ | |
54 | rm -r $out/config | |
55 | ln -sf ${varDir}/config $out/config | |
56 | ''; | |
57 | ||
65b715d7 | 58 | passthru = toPassthru package [] otherConfig; |
0ede7366 IB |
59 | meta = { |
60 | description = "Sharing solution for files, calendars, contacts and more"; | |
61 | homepage = https://nextcloud.com; | |
62 | maintainers = with lib.maintainers; [ schneefux bachp globin fpletz ]; | |
63 | license = lib.licenses.agpl3Plus; | |
64 | platforms = with lib.platforms; unix; | |
65 | }; | |
66 | }; | |
67 | in package |