diff options
author | Ismaël Bouya <ismael.bouya@normalesup.org> | 2023-10-04 01:35:06 +0200 |
---|---|---|
committer | Ismaël Bouya <ismael.bouya@normalesup.org> | 2023-10-04 02:11:48 +0200 |
commit | 1a64deeb894dc95e2645a75771732c6cc53a79ad (patch) | |
tree | 1b9df4838f894577a09b9b260151756272efeb53 /flakes/mypackages/pkgs/webapps/nextcloud/default.nix | |
parent | fa25ffd4583cc362075cd5e1b4130f33306103f0 (diff) | |
download | Nix-1a64deeb894dc95e2645a75771732c6cc53a79ad.tar.gz Nix-1a64deeb894dc95e2645a75771732c6cc53a79ad.tar.zst Nix-1a64deeb894dc95e2645a75771732c6cc53a79ad.zip |
Squash changes containing private information
There were a lot of changes since the previous commit, but a lot of them
contained personnal information about users. All thos changes got
stashed into a single commit (history is kept in a different place) and
private information was moved in a separate private repository
Diffstat (limited to 'flakes/mypackages/pkgs/webapps/nextcloud/default.nix')
-rw-r--r-- | flakes/mypackages/pkgs/webapps/nextcloud/default.nix | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/flakes/mypackages/pkgs/webapps/nextcloud/default.nix b/flakes/mypackages/pkgs/webapps/nextcloud/default.nix new file mode 100644 index 0000000..6aeeaed --- /dev/null +++ b/flakes/mypackages/pkgs/webapps/nextcloud/default.nix | |||
@@ -0,0 +1,84 @@ | |||
1 | { nextcloudVersion, otherConfig ? {}, lib, stdenv, callPackage, fetchzip, fetchurl, postInstall ? null }: | ||
2 | let | ||
3 | shasumsAndVersion = { | ||
4 | "25" = { sum = "sha256-alvh0fWESSS5KbfiKI1gaoahisDWnfT/bUhsSEEXfQI="; fullVersion = "25.0.10"; }; # php 7.4 - 8.2 | ||
5 | "26" = { sum = "sha256-nhq0aAY4T1hUZdKJY66ZSlirCSgPQet8YJpciwJw1b4="; fullVersion = "26.0.5"; }; # php 8.0 - 8.2 | ||
6 | "27" = { sum = "sha256-ei3OpDqjuPswM0fv2kxvN3M8yhE8juFt2fDl+2jHIS8="; fullVersion = "27.0.2"; }; # php 8.0 - 8.2 | ||
7 | }; | ||
8 | appNames = [ | ||
9 | "audioplayer" "bookmarks" "calendar" "carnet" | ||
10 | "contacts" "cookbook" "deck" "external" "extract" "files_markdown" "files_mindmap" | ||
11 | "files_readmemd" "flowupload" "gpxedit" "gpxpod" "groupfolders" "impersonate" | ||
12 | "keeweb" "maps" "metadata" "music" "notes" "ocsms" "onlyoffice" "passman" "polls" | ||
13 | "social" "spreed" "talk_matterbridge" "tasks" "drawio" "side_menu" | ||
14 | "integration_dropbox" | ||
15 | ]; | ||
16 | toApp = name: callPackage (./apps + "/${name}.nix") { inherit buildApp nextcloudVersion; }; | ||
17 | allSupportedApps = lib.mapAttrs (n: v: v.value) (lib.filterAttrs (n: v: v.success) (lib.genAttrs appNames (name: builtins.tryEval (toApp name)))); | ||
18 | allApps = lib.genAttrs appNames toApp; | ||
19 | buildApp = { appName, version, filename ? null, url, sha256, installHook ? (n: ""), otherConfig ? {}, installPhase ? "mkdir -p $out && cp -R . $out/" }: | ||
20 | stdenv.mkDerivation rec { | ||
21 | name = "nextcloud-app-${appName}-${version}"; | ||
22 | inherit version; | ||
23 | phases = "unpackPhase installPhase"; | ||
24 | inherit installPhase; | ||
25 | src = fetchurl ({ inherit url sha256; } // lib.optionalAttrs (filename != null) { name = filename; }); | ||
26 | passthru = { | ||
27 | inherit appName otherConfig installHook; | ||
28 | }; | ||
29 | }; | ||
30 | toPassthru = pkg: apps: otherConfig: { | ||
31 | inherit apps otherConfig allApps allSupportedApps buildApp; | ||
32 | withApps = withApps pkg; | ||
33 | }; | ||
34 | withApps = pkg: toApps: | ||
35 | let | ||
36 | apps = toApps allApps; | ||
37 | toInstallApp = n: '' | ||
38 | if [ -e $out/apps/${n.appName} ]; then | ||
39 | echo "${n.appName} already exists" | ||
40 | false | ||
41 | fi | ||
42 | ln -sf ${n} $out/apps/${n.appName} | ||
43 | '' + (n.installHook n); | ||
44 | zipped = lib.attrsets.zipAttrs ([pkg.otherConfig or {}] ++ map (v: v.otherConfig) apps); | ||
45 | appConfigs = with lib.attrsets; with lib.lists; { | ||
46 | mimetypealiases = foldr (h: prev: prev // h) {} (zipped.mimetypealiases or []); | ||
47 | mimetypemapping = mapAttrs (_: v: unique (flatten v)) (zipAttrs (zipped.mimetypemapping or [])); | ||
48 | }; | ||
49 | newNextcloud = pkg.overrideAttrs(old: { | ||
50 | installPhase = old.installPhase + "\n" + builtins.concatStringsSep "\n" (map toInstallApp apps); | ||
51 | passthru = toPassthru newNextcloud (pkg.apps ++ apps) appConfigs; | ||
52 | }); | ||
53 | in newNextcloud; | ||
54 | package = stdenv.mkDerivation rec { | ||
55 | name = "nextcloud-${version}"; | ||
56 | version = shasumsAndVersion."${builtins.toString nextcloudVersion}".fullVersion; | ||
57 | |||
58 | src = fetchurl { | ||
59 | url = "https://download.nextcloud.com/server/releases/${name}.tar.bz2"; | ||
60 | sha256 = shasumsAndVersion."${builtins.toString nextcloudVersion}".sum; | ||
61 | }; | ||
62 | |||
63 | inherit postInstall; | ||
64 | installPhase = '' | ||
65 | mkdir -p $out/ | ||
66 | cp -R . $out/ | ||
67 | sed -i -e "/'appDirsWithDifferentOwner'/d" $out/apps/settings/lib/Controller/CheckSetupController.php | ||
68 | mv $out/config $out/config.example | ||
69 | runHook postInstall | ||
70 | ''; | ||
71 | |||
72 | noAuditTmpdir = true; | ||
73 | dontPatchELF = true; | ||
74 | dontStrip = true; | ||
75 | passthru = toPassthru package [] otherConfig; | ||
76 | meta = { | ||
77 | description = "Sharing solution for files, calendars, contacts and more"; | ||
78 | homepage = https://nextcloud.com; | ||
79 | maintainers = with lib.maintainers; [ schneefux bachp globin fpletz ]; | ||
80 | license = lib.licenses.agpl3Plus; | ||
81 | platforms = with lib.platforms; unix; | ||
82 | }; | ||
83 | }; | ||
84 | in package | ||