1 { varDir ? "/var/lib/nextcloud", nextcloudVersion ? 18, otherConfig ? {}, lib, stdenv, callPackage, fetchzip, fetchurl }:
4 "apporder" "audioplayer" "bookmarks" "calendar" "carnet" "circles"
5 "contacts" "cookbook" "deck" "extract" "files_markdown" "files_mindmap"
6 "files_readmemd" "flowupload" "gpxedit" "gpxpod" "impersonate"
7 "keeweb" "maps" "metadata" "music" "notes" "ocsms" "passman" "polls"
8 "spreed" "social" "tasks"
10 allApps = lib.attrsets.genAttrs appNames
11 (name: callPackage (./apps + "/${name}.nix") { inherit buildApp nextcloudVersion; });
12 buildApp = { appName, version, url, sha256, zip ? false, installHook ? (n: ""), otherConfig ? {}, installPhase ? "mkdir -p $out && cp -R . $out/" }:
13 stdenv.mkDerivation rec {
14 name = "nextcloud-app-${appName}-${version}";
16 phases = "unpackPhase installPhase";
18 src = (if zip then fetchzip else fetchurl) { inherit url sha256; };
20 inherit appName otherConfig installHook;
23 toPassthru = pkg: apps: otherConfig: {
24 inherit apps otherConfig allApps buildApp varDir;
25 withApps = withApps pkg;
27 withApps = pkg: toApps:
29 apps = toApps allApps;
31 ln -sf ${n} $out/apps/${n.appName}
32 '' + (n.installHook n);
33 zipped = lib.attrsets.zipAttrs ([pkg.otherConfig or {}] ++ map (v: v.otherConfig) apps);
34 appConfigs = with lib.attrsets; with lib.lists; {
35 mimetypealiases = foldr (h: prev: prev // h) {} (zipped.mimetypealiases or []);
36 mimetypemapping = mapAttrs (_: v: unique (flatten v)) (zipAttrs (zipped.mimetypemapping or []));
38 newNextcloud = pkg.overrideAttrs(old: {
39 installPhase = old.installPhase + "\n" + builtins.concatStringsSep "\n" (map toInstallApp apps);
40 passthru = toPassthru newNextcloud (pkg.apps ++ apps) appConfigs;
43 package = stdenv.mkDerivation rec {
44 name = "nextcloud-${version}";
45 version = "${builtins.toString nextcloudVersion}.0.4";
48 url = "https://download.nextcloud.com/server/releases/${name}.tar.bz2";
49 sha256 = "0aa3f4xbkzacfw0h9aic0ywk5mqlwka83qaszizj8lmk68kf3n7s";
56 '' + lib.optionalString (varDir != null) ''
57 ln -sf ${varDir}/config $out/config
60 passthru = toPassthru package [] otherConfig;
62 description = "Sharing solution for files, calendars, contacts and more";
63 homepage = https://nextcloud.com;
64 maintainers = with lib.maintainers; [ schneefux bachp globin fpletz ];
65 license = lib.licenses.agpl3Plus;
66 platforms = with lib.platforms; unix;