X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=pkgs%2Fwebapps%2Fnextcloud%2Fdefault.nix;h=c6677db6b848d332d8f734c52424c739eb213bb4;hb=792ccef2c82a055a2cc4801de028312b0b1199ea;hp=2d4eb3909dcd5bb47300370b8b6b8fe06a22b584;hpb=e6abbae25ce533e8d38a0e8318b1d5d5a35d813d;p=perso%2FImmae%2FConfig%2FNix.git diff --git a/pkgs/webapps/nextcloud/default.nix b/pkgs/webapps/nextcloud/default.nix index 2d4eb39..c6677db 100644 --- a/pkgs/webapps/nextcloud/default.nix +++ b/pkgs/webapps/nextcloud/default.nix @@ -1,6 +1,22 @@ -{ 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; @@ -8,50 +24,52 @@ let 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 = old.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); - }; - inherit apps; - withApps = moreApps: old.withApps (moreApps ++ apps); - }; - }); - + 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 [])); + }; + 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;