]> git.immae.eu Git - perso/Immae/Config/Nix.git/blame - pkgs/webapps/nextcloud/default.nix
Add bakeer’s website
[perso/Immae/Config/Nix.git] / pkgs / webapps / nextcloud / default.nix
CommitLineData
50def592 1{ varDir ? "/var/lib/nextcloud", nextcloudVersion ? 18, otherConfig ? {}, lib, stdenv, callPackage, fetchzip, fetchurl }:
0ede7366 2let
65b715d7 3 appNames = [
051f375c
IB
4 "apporder" "audioplayer" "bookmarks" "calendar" "carnet" "circles"
5 "contacts" "cookbook" "deck" "extract" "files_markdown"
abd7458c
IB
6 "files_readmemd" "flowupload" "gpxedit" "gpxpod" "impersonate"
7 "keeweb" "maps" "metadata" "music" "notes" "ocsms" "passman" "polls"
8 "spreed" "social" "tasks"
65b715d7
IB
9 ];
10 allApps = lib.attrsets.genAttrs appNames
11 (name: callPackage (./apps + "/${name}.nix") { inherit buildApp nextcloudVersion; });
50def592 12 buildApp = { appName, version, url, sha256, zip ? false, otherConfig ? {}, installPhase ? "mkdir -p $out && cp -R . $out/" }:
0ede7366
IB
13 stdenv.mkDerivation rec {
14 name = "nextcloud-app-${appName}-${version}";
15 inherit version;
16 phases = "unpackPhase installPhase";
17 inherit installPhase;
50def592 18 src = (if zip then fetchzip else fetchurl) { inherit url sha256; };
3a1461cf
IB
19 passthru = {
20 inherit appName otherConfig;
21 };
0ede7366 22 };
65b715d7
IB
23 toPassthru = pkg: apps: otherConfig: {
24 inherit apps otherConfig allApps buildApp varDir;
25 withApps = withApps pkg;
26 };
27 withApps = pkg: toApps:
28 let
29 apps = toApps allApps;
30 toInstallApp = n: ''
31 ln -sf ${n} $out/apps/${n.appName}
32 '';
33 zipped = lib.attrsets.zipAttrs ([pkg.otherConfig or {}] ++ map (v: v.otherConfig) apps);
34 appConfigs = with lib.attrsets; with lib.lists; {
35 mimetypealiases = foldr (h: prev: prev // h) {} (zipped.mimetypealiases or []);
36 mimetypemapping = mapAttrs (_: v: unique (flatten v)) (zipAttrs (zipped.mimetypemapping or []));
37 };
38 newNextcloud = pkg.overrideAttrs(old: {
39 installPhase = old.installPhase + "\n" + builtins.concatStringsSep "\n" (map toInstallApp apps);
40 passthru = toPassthru newNextcloud (pkg.apps ++ apps) appConfigs;
41 });
42 in newNextcloud;
0ede7366
IB
43 package = stdenv.mkDerivation rec {
44 name = "nextcloud-${version}";
c4216ddb 45 version = "${builtins.toString nextcloudVersion}.0.4";
0ede7366
IB
46
47 src = fetchurl {
48 url = "https://download.nextcloud.com/server/releases/${name}.tar.bz2";
c4216ddb 49 sha256 = "0aa3f4xbkzacfw0h9aic0ywk5mqlwka83qaszizj8lmk68kf3n7s";
0ede7366
IB
50 };
51
52 installPhase = ''
53 mkdir -p $out/
54 cp -R . $out/
55 rm -r $out/config
1ddb9a44
IB
56 '' + lib.optionalString (varDir != null) ''
57 ln -sf ${varDir}/config $out/config
0ede7366
IB
58 '';
59
65b715d7 60 passthru = toPassthru package [] otherConfig;
0ede7366
IB
61 meta = {
62 description = "Sharing solution for files, calendars, contacts and more";
63 homepage = https://nextcloud.com;
64 maintainers = with lib.maintainers; [ schneefux bachp globin fpletz ];
65 license = lib.licenses.agpl3Plus;
66 platforms = with lib.platforms; unix;
67 };
68 };
69in package