-{ varDir ? "/var/lib/nextcloud", otherConfig ? {}, lib, stdenv, fetchurl }:
+{ varDir ? "/var/lib/nextcloud", nextcloudVersion, otherConfig ? {}, lib, stdenv, callPackage, fetchzip, fetchurl }:
let
- buildApp = { appName, version, url, sha256, otherConfig ? {}, installPhase ? "mkdir -p $out && cp -R . $out/" }:
+ shasumsAndVersion = {
+ "20" = { sum = "0rwky0d5i5glck5xxfsa9ygd0v2wf58k2q4ipmyvgq4rki2jqr89"; fullVersion = "20.0.14"; };
+ "21" = { sum = "1dqk2lpqc08qld8znp5vpcm8j8j8spfgvl8ax9faxpmmdrcj34sr"; fullVersion = "21.0.7"; };
+ "22" = { sum = "0allxfcnhh4bkp4s66b47smsn7y9qxlcnxxnxnmw0f0795m9m8k6"; fullVersion = "22.2.3"; };
+ "23" = { sum = "0b0ss1svxyg3kfbymhn85zspmf0lyhj1la2rhk98yp5nqfmr4xf3"; fullVersion = "23.0.0"; };
+ };
+ appNames = [
+ "apporder" "audioplayer" "bookmarks" "calendar" "carnet" "circles"
+ "contacts" "cookbook" "deck" "external" "extract" "files_markdown" "files_mindmap"
+ "files_readmemd" "flowupload" "gpxedit" "gpxpod" "groupfolders" "impersonate"
+ "keeweb" "maps" "metadata" "music" "notes" "ocsms" "onlyoffice" "passman" "polls"
+ "social" "spreed" "talk_matterbridge" "tasks" "drawio"
+ ];
+ toApp = name: callPackage (./apps + "/${name}.nix") { inherit buildApp nextcloudVersion; };
+ allSupportedApps = lib.mapAttrs (n: v: v.value) (lib.filterAttrs (n: v: v.success) (lib.genAttrs appNames (name: builtins.tryEval (toApp name))));
+ allApps = lib.genAttrs appNames toApp;
+ buildApp = { appName, version, url, sha256, installHook ? (n: ""), otherConfig ? {}, installPhase ? "mkdir -p $out && cp -R . $out/" }:
stdenv.mkDerivation rec {
name = "nextcloud-app-${appName}-${version}";
inherit version;
inherit installPhase;
src = fetchurl { inherit url sha256; };
passthru = {
- inherit appName otherConfig;
+ inherit appName otherConfig installHook;
};
};
- withApps = apps: package.overrideAttrs(old: {
- name = "${old.name}-with-apps";
-
- installPhase = old.installPhase + (
- builtins.concatStringsSep "\n" (
- map (value: "ln -sf ${value} $out/apps/${value.appName}") apps
- ));
-
- passthru.otherConfig = with lib.attrsets; with lib.lists; let
- zipped = zipAttrs ([old.otherConfig or {}] ++ map (v: v.otherConfig) apps);
- in
- {
- mimetypealiases = foldr (h: prev: prev // h) {} zipped.mimetypealiases;
- mimetypemapping = mapAttrs (_: v: unique (flatten v)) (zipAttrs zipped.mimetypemapping);
+ toPassthru = pkg: apps: otherConfig: {
+ inherit apps otherConfig allApps allSupportedApps buildApp varDir;
+ withApps = withApps pkg;
+ };
+ withApps = pkg: toApps:
+ let
+ apps = toApps allApps;
+ toInstallApp = n: ''
+ if [ -e $out/apps/${n.appName} ]; then
+ echo "${n.appName} already exists"
+ false
+ fi
+ ln -sf ${n} $out/apps/${n.appName}
+ '' + (n.installHook n);
+ zipped = lib.attrsets.zipAttrs ([pkg.otherConfig or {}] ++ map (v: v.otherConfig) apps);
+ appConfigs = with lib.attrsets; with lib.lists; {
+ mimetypealiases = foldr (h: prev: prev // h) {} (zipped.mimetypealiases or []);
+ mimetypemapping = mapAttrs (_: v: unique (flatten v)) (zipAttrs (zipped.mimetypemapping or []));
};
- passthru.apps = apps;
- passthru.withApps = moreApps: old.withApps (moreApps ++ apps);
- });
-
+ newNextcloud = pkg.overrideAttrs(old: {
+ installPhase = old.installPhase + "\n" + builtins.concatStringsSep "\n" (map toInstallApp apps);
+ passthru = toPassthru newNextcloud (pkg.apps ++ apps) appConfigs;
+ });
+ in newNextcloud;
package = stdenv.mkDerivation rec {
name = "nextcloud-${version}";
- version = "16.0.0";
+ version = shasumsAndVersion."${builtins.toString nextcloudVersion}".fullVersion;
src = fetchurl {
url = "https://download.nextcloud.com/server/releases/${name}.tar.bz2";
- sha256 = "0bj014vczlrql1w32pqmr7cyqn9awnyzpi2syxhg16qxic1gfcj5";
+ sha256 = shasumsAndVersion."${builtins.toString nextcloudVersion}".sum;
};
installPhase = ''
mkdir -p $out/
cp -R . $out/
+ sed -i -e "/'appDirsWithDifferentOwner'/d" $out/apps/settings/lib/Controller/CheckSetupController.php
rm -r $out/config
- ln -sf ${varDir}/config $out/config
+ '' + lib.optionalString (varDir != null) ''
+ ln -sf ${varDir}/config $out/config
'';
- passthru = {
- apps = [];
- inherit otherConfig buildApp withApps varDir;
- };
+ passthru = toPassthru package [] otherConfig;
meta = {
description = "Sharing solution for files, calendars, contacts and more";
homepage = https://nextcloud.com;