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