1 { varDir ? "/var/lib/nextcloud", nextcloudVersion, otherConfig ? {}, lib, stdenv, callPackage, fetchzip, fetchurl }:
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"; };
10 "apporder" "audioplayer" "bookmarks" "calendar" "carnet" "circles"
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"
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/" }:
20 stdenv.mkDerivation rec {
21 name = "nextcloud-app-${appName}-${version}";
23 phases = "unpackPhase installPhase";
25 src = fetchurl { inherit url sha256; };
27 inherit appName otherConfig installHook;
30 toPassthru = pkg: apps: otherConfig: {
31 inherit apps otherConfig allApps allSupportedApps buildApp varDir;
32 withApps = withApps pkg;
34 withApps = pkg: toApps:
36 apps = toApps allApps;
38 if [ -e $out/apps/${n.appName} ]; then
39 echo "${n.appName} already exists"
42 ln -sf ${n} $out/apps/${n.appName}
43 '' + (n.installHook n);
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 []));
49 newNextcloud = pkg.overrideAttrs(old: {
50 installPhase = old.installPhase + "\n" + builtins.concatStringsSep "\n" (map toInstallApp apps);
51 passthru = toPassthru newNextcloud (pkg.apps ++ apps) appConfigs;
54 package = stdenv.mkDerivation rec {
55 name = "nextcloud-${version}";
56 version = shasumsAndVersion."${builtins.toString nextcloudVersion}".fullVersion;
59 url = "https://download.nextcloud.com/server/releases/${name}.tar.bz2";
60 sha256 = shasumsAndVersion."${builtins.toString nextcloudVersion}".sum;
66 sed -i -e "/'appDirsWithDifferentOwner'/d" $out/apps/settings/lib/Controller/CheckSetupController.php
68 '' + lib.optionalString (varDir != null) ''
69 ln -sf ${varDir}/config $out/config
72 passthru = toPassthru package [] otherConfig;
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;