aboutsummaryrefslogtreecommitdiff
path: root/pkgs/webapps/nextcloud/default.nix
blob: c3471fe6b35989e74bc2c2ec7df8948b93c6b739 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
{ varDir ? "/var/lib/nextcloud", lib, stdenv, fetchurl }:
let
  buildApp = { appName, version, url, sha256, installPhase ? "mkdir -p $out && cp -R . $out/" }:
    stdenv.mkDerivation rec {
      name = "nextcloud-app-${appName}-${version}";
      inherit version;
      phases = "unpackPhase installPhase";
      inherit installPhase;
      src = fetchurl { inherit url sha256; };
      passthru.appName = appName;
    };
  withApps = apps: package.overrideAttrs(old: {
    name = "${old.name}-with-apps";

    installPhase = old.installPhase + (
      builtins.concatStringsSep "\n" (
        map (value: "ln -sf ${value} $out/apps/${value.appName}") apps
      ));
    passthru.apps = apps;
    passthru.withApps = moreApps: old.withApps (moreApps ++ apps);
  });

  package = stdenv.mkDerivation rec {
    name = "nextcloud-${version}";
    version = "15.0.4";

    src = fetchurl {
      url = "https://download.nextcloud.com/server/releases/${name}.tar.bz2";
      sha256 = "0xwg7p31y1pkjk1pzygh9shpqxnfkafrab52j7in7xblq53v0zgq";
    };

    installPhase = ''
      mkdir -p $out/
      cp -R . $out/
      rm -r $out/config
      ln -sf ${varDir}/config $out/config
      '';

    passthru = {
      apps = [];
      inherit buildApp withApps varDir;
    };
    meta = {
      description = "Sharing solution for files, calendars, contacts and more";
      homepage = https://nextcloud.com;
      maintainers = with lib.maintainers; [ schneefux bachp globin fpletz ];
      license = lib.licenses.agpl3Plus;
      platforms = with lib.platforms; unix;
    };
  };
in package