]>
Commit | Line | Data |
---|---|---|
1 | { nextcloudVersion, otherConfig ? {}, lib, stdenv, callPackage, fetchzip, fetchurl, postInstall ? null }: | |
2 | let | |
3 | shasumsAndVersion = { | |
4 | "25" = { sum = "sha256-alvh0fWESSS5KbfiKI1gaoahisDWnfT/bUhsSEEXfQI="; fullVersion = "25.0.10"; }; # php 7.4 - 8.2 | |
5 | "26" = { sum = "sha256-nhq0aAY4T1hUZdKJY66ZSlirCSgPQet8YJpciwJw1b4="; fullVersion = "26.0.5"; }; # php 8.0 - 8.2 | |
6 | "27" = { sum = "sha256-O1NMmOdrf+2Mo5NMrUGbEK9YViWfMTvsIs06e/pu+WE="; fullVersion = "27.1.5"; }; # php 8.0 - 8.2 | |
7 | }; | |
8 | appNames = [ | |
9 | "audioplayer" "bookmarks" "calendar" "carnet" | |
10 | "contacts" "cookbook" "deck" "external" "extract" "files_markdown" "files_mindmap" | |
11 | "files_readmemd" "flowupload" "gpxedit" "gpxpod" "groupfolders" "impersonate" | |
12 | "keeweb" "maps" "metadata" "music" "notes" "ocsms" "onlyoffice" "passman" "polls" | |
13 | "social" "spreed" "talk_matterbridge" "tasks" "drawio" "side_menu" | |
14 | "integration_dropbox" | |
15 | ]; | |
16 | toApp = name: callPackage (./apps + "/${name}.nix") { inherit buildApp nextcloudVersion; }; | |
17 | allSupportedApps = lib.mapAttrs (n: v: v.value) (lib.filterAttrs (n: v: v.success) (lib.genAttrs appNames (name: builtins.tryEval (toApp name)))); | |
18 | allApps = lib.genAttrs appNames toApp; | |
19 | buildApp = { appName, version, filename ? null, url, sha256, installHook ? (n: ""), otherConfig ? {}, installPhase ? "mkdir -p $out && cp -R . $out/" }: | |
20 | stdenv.mkDerivation rec { | |
21 | name = "nextcloud-app-${appName}-${version}"; | |
22 | inherit version; | |
23 | phases = "unpackPhase installPhase"; | |
24 | inherit installPhase; | |
25 | src = fetchurl ({ inherit url sha256; } // lib.optionalAttrs (filename != null) { name = filename; }); | |
26 | passthru = { | |
27 | inherit appName otherConfig installHook; | |
28 | }; | |
29 | }; | |
30 | toPassthru = pkg: apps: otherConfig: { | |
31 | inherit apps otherConfig allApps allSupportedApps buildApp; | |
32 | withApps = withApps pkg; | |
33 | }; | |
34 | withApps = pkg: toApps: | |
35 | let | |
36 | apps = toApps allApps; | |
37 | toInstallApp = n: '' | |
38 | if [ -e $out/apps/${n.appName} ]; then | |
39 | echo "${n.appName} already exists" | |
40 | false | |
41 | fi | |
42 | ln -sf ${n} $out/apps/${n.appName} | |
43 | '' + (n.installHook n); | |
44 | zipped = lib.attrsets.zipAttrs ([pkg.otherConfig or {}] ++ map (v: v.otherConfig) apps); | |
45 | appConfigs = with lib.attrsets; with lib.lists; { | |
46 | mimetypealiases = foldr (h: prev: prev // h) {} (zipped.mimetypealiases or []); | |
47 | mimetypemapping = mapAttrs (_: v: unique (flatten v)) (zipAttrs (zipped.mimetypemapping or [])); | |
48 | }; | |
49 | newNextcloud = pkg.overrideAttrs(old: { | |
50 | installPhase = old.installPhase + "\n" + builtins.concatStringsSep "\n" (map toInstallApp apps); | |
51 | passthru = toPassthru newNextcloud (pkg.apps ++ apps) appConfigs; | |
52 | }); | |
53 | in newNextcloud; | |
54 | package = stdenv.mkDerivation rec { | |
55 | name = "nextcloud-${version}"; | |
56 | version = shasumsAndVersion."${builtins.toString nextcloudVersion}".fullVersion; | |
57 | ||
58 | src = fetchurl { | |
59 | url = "https://download.nextcloud.com/server/releases/${name}.tar.bz2"; | |
60 | sha256 = shasumsAndVersion."${builtins.toString nextcloudVersion}".sum; | |
61 | }; | |
62 | ||
63 | inherit postInstall; | |
64 | installPhase = '' | |
65 | mkdir -p $out/ | |
66 | cp -R . $out/ | |
67 | sed -i -e "/'appDirsWithDifferentOwner'/d" $out/apps/settings/lib/Controller/CheckSetupController.php | |
68 | mv $out/config $out/config.example | |
69 | runHook postInstall | |
70 | ''; | |
71 | ||
72 | noAuditTmpdir = true; | |
73 | dontPatchELF = true; | |
74 | dontStrip = true; | |
75 | passthru = toPassthru package [] otherConfig; | |
76 | meta = { | |
77 | description = "Sharing solution for files, calendars, contacts and more"; | |
78 | homepage = https://nextcloud.com; | |
79 | maintainers = with lib.maintainers; [ schneefux bachp globin fpletz ]; | |
80 | license = lib.licenses.agpl3Plus; | |
81 | platforms = with lib.platforms; unix; | |
82 | }; | |
83 | }; | |
84 | in package |