]> git.immae.eu Git - perso/Immae/Config/Nix.git/blame - pkgs/webapps/nextcloud/default.nix
Fix passthru’s in pkgs
[perso/Immae/Config/Nix.git] / pkgs / webapps / nextcloud / default.nix
CommitLineData
3a1461cf 1{ varDir ? "/var/lib/nextcloud", otherConfig ? {}, lib, stdenv, fetchurl }:
0ede7366 2let
3a1461cf 3 buildApp = { appName, version, url, sha256, otherConfig ? {}, installPhase ? "mkdir -p $out && cp -R . $out/" }:
0ede7366
IB
4 stdenv.mkDerivation rec {
5 name = "nextcloud-app-${appName}-${version}";
6 inherit version;
7 phases = "unpackPhase installPhase";
8 inherit installPhase;
9 src = fetchurl { inherit url sha256; };
3a1461cf
IB
10 passthru = {
11 inherit appName otherConfig;
12 };
0ede7366
IB
13 };
14 withApps = apps: package.overrideAttrs(old: {
15 name = "${old.name}-with-apps";
16
17 installPhase = old.installPhase + (
18 builtins.concatStringsSep "\n" (
19 map (value: "ln -sf ${value} $out/apps/${value.appName}") apps
20 ));
3a1461cf 21
e6abbae2
IB
22 passthru = old.passthru // {
23 otherConfig = with lib.attrsets; with lib.lists; let
24 zipped = zipAttrs ([old.otherConfig or {}] ++ map (v: v.otherConfig) apps);
25 in
26 {
27 mimetypealiases = foldr (h: prev: prev // h) {} zipped.mimetypealiases;
28 mimetypemapping = mapAttrs (_: v: unique (flatten v)) (zipAttrs zipped.mimetypemapping);
29 };
30 inherit apps;
31 withApps = moreApps: old.withApps (moreApps ++ apps);
32 };
0ede7366
IB
33 });
34
35 package = stdenv.mkDerivation rec {
36 name = "nextcloud-${version}";
3a1461cf 37 version = "16.0.0";
0ede7366
IB
38
39 src = fetchurl {
40 url = "https://download.nextcloud.com/server/releases/${name}.tar.bz2";
3a1461cf 41 sha256 = "0bj014vczlrql1w32pqmr7cyqn9awnyzpi2syxhg16qxic1gfcj5";
0ede7366
IB
42 };
43
44 installPhase = ''
45 mkdir -p $out/
46 cp -R . $out/
47 rm -r $out/config
48 ln -sf ${varDir}/config $out/config
49 '';
50
51 passthru = {
52 apps = [];
3a1461cf 53 inherit otherConfig buildApp withApps varDir;
0ede7366
IB
54 };
55 meta = {
56 description = "Sharing solution for files, calendars, contacts and more";
57 homepage = https://nextcloud.com;
58 maintainers = with lib.maintainers; [ schneefux bachp globin fpletz ];
59 license = lib.licenses.agpl3Plus;
60 platforms = with lib.platforms; unix;
61 };
62 };
63in package