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