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