]> git.immae.eu Git - perso/Immae/Config/Nix.git/blobdiff - pkgs/webapps/nextcloud/default.nix
Upgrade nextcloud
[perso/Immae/Config/Nix.git] / pkgs / webapps / nextcloud / default.nix
index 2d4eb3909dcd5bb47300370b8b6b8fe06a22b584..fecb3a7b9cb2cfe5413c32ef23c8a69b57b0b33f 100644 (file)
@@ -1,5 +1,13 @@
-{ varDir ? "/var/lib/nextcloud", otherConfig ? {}, lib, stdenv, fetchurl }:
+{ varDir ? "/var/lib/nextcloud", nextcloudVersion ? 17, otherConfig ? {}, lib, stdenv, callPackage, fetchurl }:
 let
+  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"
+  ];
+  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/" }:
     stdenv.mkDerivation rec {
       name = "nextcloud-app-${appName}-${version}";
@@ -11,34 +19,33 @@ let
         inherit appName otherConfig;
       };
     };
-  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 buildApp varDir;
+    withApps = withApps pkg;
+  };
+  withApps = pkg: toApps:
+    let
+      apps = toApps allApps;
+      toInstallApp = n: ''
+        ln -sf ${n} $out/apps/${n.appName}
+      '';
+      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 = "${builtins.toString nextcloudVersion}.0.6";
 
     src = fetchurl {
       url = "https://download.nextcloud.com/server/releases/${name}.tar.bz2";
-      sha256 = "0bj014vczlrql1w32pqmr7cyqn9awnyzpi2syxhg16qxic1gfcj5";
+      sha256 = "0qq7lkgzsn1zakfym5bjqzpcisxmgfcdd927ddqlhddy3zvgxrxx";
     };
 
     installPhase = ''
@@ -48,10 +55,7 @@ let
       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;