]> git.immae.eu Git - perso/Immae/Config/Nix.git/blobdiff - pkgs/webapps/nextcloud/default.nix
Bump Nextcloud to latest version
[perso/Immae/Config/Nix.git] / pkgs / webapps / nextcloud / default.nix
index fecb3a7b9cb2cfe5413c32ef23c8a69b57b0b33f..c6677db6b848d332d8f734c52424c739eb213bb4 100644 (file)
@@ -1,14 +1,22 @@
-{ varDir ? "/var/lib/nextcloud", nextcloudVersion ? 17, otherConfig ? {}, lib, stdenv, callPackage, fetchurl }:
+{ varDir ? "/var/lib/nextcloud", nextcloudVersion, otherConfig ? {}, lib, stdenv, callPackage, fetchzip, fetchurl }:
 let
+  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" "contacts"
-    "cookbook" "deck" "extract" "files_markdown" "files_readmemd"
-    "flowupload" "gpxedit" "gpxpod" "keeweb" "maps" "metadata" "music"
-    "notes" "ocsms" "passman" "polls" "spreed" "tasks"
+    "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"
   ];
-  allApps = lib.attrsets.genAttrs appNames
-    (name: callPackage (./apps + "/${name}.nix") { inherit buildApp nextcloudVersion; });
-  buildApp = { appName, version, url, sha256, otherConfig ? {}, installPhase ? "mkdir -p $out && cp -R . $out/" }:
+  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;
@@ -16,19 +24,23 @@ let
       inherit installPhase;
       src = fetchurl { inherit url sha256; };
       passthru = {
-        inherit appName otherConfig;
+        inherit appName otherConfig installHook;
       };
     };
   toPassthru = pkg: apps: otherConfig: {
-    inherit apps otherConfig allApps buildApp varDir;
+    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 []);
@@ -41,18 +53,20 @@ let
     in newNextcloud;
   package = stdenv.mkDerivation rec {
     name = "nextcloud-${version}";
-    version = "${builtins.toString nextcloudVersion}.0.6";
+    version = shasumsAndVersion."${builtins.toString nextcloudVersion}".fullVersion;
 
     src = fetchurl {
       url = "https://download.nextcloud.com/server/releases/${name}.tar.bz2";
-      sha256 = "0qq7lkgzsn1zakfym5bjqzpcisxmgfcdd927ddqlhddy3zvgxrxx";
+      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 = toPassthru package [] otherConfig;