]> git.immae.eu Git - perso/Immae/Config/Nix.git/blob - pkgs/webapps/nextcloud/default.nix
Move nextcloud and apps to pkgs
[perso/Immae/Config/Nix.git] / pkgs / webapps / nextcloud / default.nix
1 { varDir ? "/var/lib/nextcloud", lib, stdenv, fetchurl }:
2 let
3 buildApp = { appName, version, url, sha256, 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.appName = appName;
11 };
12 withApps = apps: package.overrideAttrs(old: {
13 name = "${old.name}-with-apps";
14
15 installPhase = old.installPhase + (
16 builtins.concatStringsSep "\n" (
17 map (value: "ln -sf ${value} $out/apps/${value.appName}") apps
18 ));
19 passthru.apps = apps;
20 passthru.withApps = moreApps: old.withApps (moreApps ++ apps);
21 });
22
23 package = stdenv.mkDerivation rec {
24 name = "nextcloud-${version}";
25 version = "15.0.4";
26
27 src = fetchurl {
28 url = "https://download.nextcloud.com/server/releases/${name}.tar.bz2";
29 sha256 = "0xwg7p31y1pkjk1pzygh9shpqxnfkafrab52j7in7xblq53v0zgq";
30 };
31
32 installPhase = ''
33 mkdir -p $out/
34 cp -R . $out/
35 rm -r $out/config
36 ln -sf ${varDir}/config $out/config
37 '';
38
39 passthru = {
40 apps = [];
41 inherit buildApp withApps varDir;
42 };
43 meta = {
44 description = "Sharing solution for files, calendars, contacts and more";
45 homepage = https://nextcloud.com;
46 maintainers = with lib.maintainers; [ schneefux bachp globin fpletz ];
47 license = lib.licenses.agpl3Plus;
48 platforms = with lib.platforms; unix;
49 };
50 };
51 in package