]>
Commit | Line | Data |
---|---|---|
792ccef2 | 1 | { varDir ? "/var/lib/nextcloud", nextcloudVersion, otherConfig ? {}, lib, stdenv, callPackage, fetchzip, fetchurl }: |
0ede7366 | 2 | let |
792ccef2 IB |
3 | shasumsAndVersion = { |
4 | "20" = { sum = "0rwky0d5i5glck5xxfsa9ygd0v2wf58k2q4ipmyvgq4rki2jqr89"; fullVersion = "20.0.14"; }; | |
5 | "21" = { sum = "1dqk2lpqc08qld8znp5vpcm8j8j8spfgvl8ax9faxpmmdrcj34sr"; fullVersion = "21.0.7"; }; | |
6 | "22" = { sum = "0allxfcnhh4bkp4s66b47smsn7y9qxlcnxxnxnmw0f0795m9m8k6"; fullVersion = "22.2.3"; }; | |
7 | "23" = { sum = "0b0ss1svxyg3kfbymhn85zspmf0lyhj1la2rhk98yp5nqfmr4xf3"; fullVersion = "23.0.0"; }; | |
8 | }; | |
65b715d7 | 9 | appNames = [ |
051f375c | 10 | "apporder" "audioplayer" "bookmarks" "calendar" "carnet" "circles" |
792ccef2 IB |
11 | "contacts" "cookbook" "deck" "external" "extract" "files_markdown" "files_mindmap" |
12 | "files_readmemd" "flowupload" "gpxedit" "gpxpod" "groupfolders" "impersonate" | |
13 | "keeweb" "maps" "metadata" "music" "notes" "ocsms" "onlyoffice" "passman" "polls" | |
14 | "social" "spreed" "talk_matterbridge" "tasks" "drawio" | |
65b715d7 | 15 | ]; |
792ccef2 IB |
16 | toApp = name: callPackage (./apps + "/${name}.nix") { inherit buildApp nextcloudVersion; }; |
17 | allSupportedApps = lib.mapAttrs (n: v: v.value) (lib.filterAttrs (n: v: v.success) (lib.genAttrs appNames (name: builtins.tryEval (toApp name)))); | |
18 | allApps = lib.genAttrs appNames toApp; | |
19 | buildApp = { appName, version, url, sha256, installHook ? (n: ""), otherConfig ? {}, installPhase ? "mkdir -p $out && cp -R . $out/" }: | |
0ede7366 IB |
20 | stdenv.mkDerivation rec { |
21 | name = "nextcloud-app-${appName}-${version}"; | |
22 | inherit version; | |
23 | phases = "unpackPhase installPhase"; | |
24 | inherit installPhase; | |
792ccef2 | 25 | src = fetchurl { inherit url sha256; }; |
3a1461cf | 26 | passthru = { |
5a412244 | 27 | inherit appName otherConfig installHook; |
3a1461cf | 28 | }; |
0ede7366 | 29 | }; |
65b715d7 | 30 | toPassthru = pkg: apps: otherConfig: { |
792ccef2 | 31 | inherit apps otherConfig allApps allSupportedApps buildApp varDir; |
65b715d7 IB |
32 | withApps = withApps pkg; |
33 | }; | |
34 | withApps = pkg: toApps: | |
35 | let | |
36 | apps = toApps allApps; | |
37 | toInstallApp = n: '' | |
792ccef2 IB |
38 | if [ -e $out/apps/${n.appName} ]; then |
39 | echo "${n.appName} already exists" | |
40 | false | |
41 | fi | |
65b715d7 | 42 | ln -sf ${n} $out/apps/${n.appName} |
5a412244 | 43 | '' + (n.installHook n); |
65b715d7 IB |
44 | zipped = lib.attrsets.zipAttrs ([pkg.otherConfig or {}] ++ map (v: v.otherConfig) apps); |
45 | appConfigs = with lib.attrsets; with lib.lists; { | |
46 | mimetypealiases = foldr (h: prev: prev // h) {} (zipped.mimetypealiases or []); | |
47 | mimetypemapping = mapAttrs (_: v: unique (flatten v)) (zipAttrs (zipped.mimetypemapping or [])); | |
48 | }; | |
49 | newNextcloud = pkg.overrideAttrs(old: { | |
50 | installPhase = old.installPhase + "\n" + builtins.concatStringsSep "\n" (map toInstallApp apps); | |
51 | passthru = toPassthru newNextcloud (pkg.apps ++ apps) appConfigs; | |
52 | }); | |
53 | in newNextcloud; | |
0ede7366 IB |
54 | package = stdenv.mkDerivation rec { |
55 | name = "nextcloud-${version}"; | |
792ccef2 | 56 | version = shasumsAndVersion."${builtins.toString nextcloudVersion}".fullVersion; |
0ede7366 IB |
57 | |
58 | src = fetchurl { | |
59 | url = "https://download.nextcloud.com/server/releases/${name}.tar.bz2"; | |
792ccef2 | 60 | sha256 = shasumsAndVersion."${builtins.toString nextcloudVersion}".sum; |
0ede7366 IB |
61 | }; |
62 | ||
63 | installPhase = '' | |
64 | mkdir -p $out/ | |
65 | cp -R . $out/ | |
792ccef2 | 66 | sed -i -e "/'appDirsWithDifferentOwner'/d" $out/apps/settings/lib/Controller/CheckSetupController.php |
0ede7366 | 67 | rm -r $out/config |
1ddb9a44 IB |
68 | '' + lib.optionalString (varDir != null) '' |
69 | ln -sf ${varDir}/config $out/config | |
0ede7366 IB |
70 | ''; |
71 | ||
65b715d7 | 72 | passthru = toPassthru package [] otherConfig; |
0ede7366 IB |
73 | meta = { |
74 | description = "Sharing solution for files, calendars, contacts and more"; | |
75 | homepage = https://nextcloud.com; | |
76 | maintainers = with lib.maintainers; [ schneefux bachp globin fpletz ]; | |
77 | license = lib.licenses.agpl3Plus; | |
78 | platforms = with lib.platforms; unix; | |
79 | }; | |
80 | }; | |
81 | in package |