From 2bd9e401fd3945dedc91c423e0c372412e9e21e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sandro=20J=C3=A4ckel?= Date: Fri, 7 Mar 2025 22:13:18 +0100 Subject: [PATCH] nextcloud31Packages.apps.memories: package by hand to remove pre-compiled binaries --- pkgs/servers/nextcloud/packages/30.json | 10 -- pkgs/servers/nextcloud/packages/31.json | 10 -- .../packages/apps/memories-paths.diff | 32 +++++++ .../nextcloud/packages/apps/memories.nix | 91 +++++++++++++++++++ .../nextcloud/packages/nextcloud-apps.json | 1 - .../servers/nextcloud/packages/thirdparty.nix | 5 +- 6 files changed, 126 insertions(+), 23 deletions(-) create mode 100644 pkgs/servers/nextcloud/packages/apps/memories-paths.diff create mode 100644 pkgs/servers/nextcloud/packages/apps/memories.nix diff --git a/pkgs/servers/nextcloud/packages/30.json b/pkgs/servers/nextcloud/packages/30.json index ec5d2edd785c..b597f4aee9f8 100644 --- a/pkgs/servers/nextcloud/packages/30.json +++ b/pkgs/servers/nextcloud/packages/30.json @@ -219,16 +219,6 @@ "agpl" ] }, - "memories": { - "hash": "sha256-BfxJDCGsiRJrZWkNJSQF3rSFm/G3zzQn7C6DCETSzw4=", - "url": "https://github.com/pulsejet/memories/releases/download/v7.5.2/memories.tar.gz", - "version": "7.5.2", - "description": "# Memories: Photo Management for Nextcloud\n\nMemories is a *batteries-included* photo management solution for Nextcloud with advanced features including:\n\n- **πŸ“Έ Timeline**: Sort photos and videos by date taken, parsed from Exif data.\n- **βͺ Rewind**: Jump to any time in the past instantly and relive your memories.\n- **πŸ€– AI Tagging**: Group photos by people and objects, powered by [recognize](https://github.com/nextcloud/recognize) and [facerecognition](https://github.com/matiasdelellis/facerecognition).\n- **πŸ–ΌοΈ Albums**: Create albums to group photos and videos together. Then share these albums with others.\n- **πŸ«±πŸ»β€πŸ«²πŸ» External Sharing**: Share photos and videos with people outside of your Nextcloud instance.\n- **πŸ“± Mobile Support**: Work from any device, of any shape and size through the web app.\n- **✏️ Edit Metadata**: Edit dates and other metadata on photos quickly and in bulk.\n- **πŸ“¦ Archive**: Store photos you don't want to see in your timeline in a separate folder.\n- **πŸ“Ή Video Transcoding**: Transcode videos and use HLS for maximal performance.\n- **πŸ—ΊοΈ Map**: View your photos on a map, tagged with accurate reverse geocoding.\n- **πŸ“¦ Migration**: Migrate easily from Nextcloud Photos and Google Takeout.\n- **⚑️ Performance**: Do all this very fast.\n\n## πŸš€ Installation\n\n1. Install the app from the Nextcloud app store (try a demo [here](https://demo.memories.gallery/apps/memories/)).\n1. Perform the recommended [configuration steps](https://memories.gallery/config/).\n1. Run `php occ memories:index` to generate metadata indices for existing photos.\n1. Open the πŸ“· Memories app in Nextcloud and set the directory containing your photos.", - "homepage": "https://memories.gallery", - "licenses": [ - "agpl" - ] - }, "music": { "hash": "sha256-h83Xc292/NQPWOTRIbUSgqHUH/Sp4fYJ8GAHSiJWHP0=", "url": "https://github.com/owncloud/music/releases/download/v2.1.4/music_2.1.4_for_nextcloud.tar.gz", diff --git a/pkgs/servers/nextcloud/packages/31.json b/pkgs/servers/nextcloud/packages/31.json index 940db23f0367..0503cc3a0d38 100644 --- a/pkgs/servers/nextcloud/packages/31.json +++ b/pkgs/servers/nextcloud/packages/31.json @@ -219,16 +219,6 @@ "agpl" ] }, - "memories": { - "hash": "sha256-BfxJDCGsiRJrZWkNJSQF3rSFm/G3zzQn7C6DCETSzw4=", - "url": "https://github.com/pulsejet/memories/releases/download/v7.5.2/memories.tar.gz", - "version": "7.5.2", - "description": "# Memories: Photo Management for Nextcloud\n\nMemories is a *batteries-included* photo management solution for Nextcloud with advanced features including:\n\n- **πŸ“Έ Timeline**: Sort photos and videos by date taken, parsed from Exif data.\n- **βͺ Rewind**: Jump to any time in the past instantly and relive your memories.\n- **πŸ€– AI Tagging**: Group photos by people and objects, powered by [recognize](https://github.com/nextcloud/recognize) and [facerecognition](https://github.com/matiasdelellis/facerecognition).\n- **πŸ–ΌοΈ Albums**: Create albums to group photos and videos together. Then share these albums with others.\n- **πŸ«±πŸ»β€πŸ«²πŸ» External Sharing**: Share photos and videos with people outside of your Nextcloud instance.\n- **πŸ“± Mobile Support**: Work from any device, of any shape and size through the web app.\n- **✏️ Edit Metadata**: Edit dates and other metadata on photos quickly and in bulk.\n- **πŸ“¦ Archive**: Store photos you don't want to see in your timeline in a separate folder.\n- **πŸ“Ή Video Transcoding**: Transcode videos and use HLS for maximal performance.\n- **πŸ—ΊοΈ Map**: View your photos on a map, tagged with accurate reverse geocoding.\n- **πŸ“¦ Migration**: Migrate easily from Nextcloud Photos and Google Takeout.\n- **⚑️ Performance**: Do all this very fast.\n\n## πŸš€ Installation\n\n1. Install the app from the Nextcloud app store (try a demo [here](https://demo.memories.gallery/apps/memories/)).\n1. Perform the recommended [configuration steps](https://memories.gallery/config/).\n1. Run `php occ memories:index` to generate metadata indices for existing photos.\n1. Open the πŸ“· Memories app in Nextcloud and set the directory containing your photos.", - "homepage": "https://memories.gallery", - "licenses": [ - "agpl" - ] - }, "music": { "hash": "sha256-h83Xc292/NQPWOTRIbUSgqHUH/Sp4fYJ8GAHSiJWHP0=", "url": "https://github.com/owncloud/music/releases/download/v2.1.4/music_2.1.4_for_nextcloud.tar.gz", diff --git a/pkgs/servers/nextcloud/packages/apps/memories-paths.diff b/pkgs/servers/nextcloud/packages/apps/memories-paths.diff new file mode 100644 index 000000000000..79f97fe72508 --- /dev/null +++ b/pkgs/servers/nextcloud/packages/apps/memories-paths.diff @@ -0,0 +1,32 @@ +diff --git a/lib/Settings/SystemConfig.php b/lib/Settings/SystemConfig.php +index 7814f071..bb1309fa 100644 +--- a/lib/Settings/SystemConfig.php ++++ b/lib/Settings/SystemConfig.php +@@ -124,6 +125,14 @@ class SystemConfig + */ + public static function get(string $key, mixed $default = null): mixed + { ++ switch ($key) { ++ case "memories.exiftool": return "@exiftool@"; ++ case "memories.exiftool_no_local": return false; ++ case "memories.vod.ffmpeg": return "@ffmpeg@"; ++ case "memories.vod.ffprobe": return "@ffprobe@"; ++ case "memories.vod.path": return "@go-vod@"; ++ } ++ + if (!\array_key_exists($key, self::DEFAULTS)) { + throw new \InvalidArgumentException("Invalid system config key: {$key}"); + } +@@ -154,6 +161,12 @@ public static function get(string $key, mixed $default = null): mixed + */ + public static function set(string $key, mixed $value): void + { ++ // Ignore those paths and always use the nix paths. ++ // We cannot return a proper error message except a 500 here without changing the code to much. ++ if (in_array($key, array("memories.exiftool", "memories.exiftool_no_local", "memories.vod.ffmpeg", "memories.vod.ffprobe", "memories.vod.path"))) { ++ throw new \InvalidArgumentException("Cannot set nix-managed key: {$key}"); ++ } ++ + // Check if the key is valid + if (!\array_key_exists($key, self::DEFAULTS)) { + throw new \InvalidArgumentException("Invalid system config key: {$key}"); diff --git a/pkgs/servers/nextcloud/packages/apps/memories.nix b/pkgs/servers/nextcloud/packages/apps/memories.nix new file mode 100644 index 000000000000..a6336c14d4b6 --- /dev/null +++ b/pkgs/servers/nextcloud/packages/apps/memories.nix @@ -0,0 +1,91 @@ +{ + stdenv, + buildGoModule, + exiftool, + fetchurl, + ffmpeg-headless, + fetchFromGitHub, + lib, + replaceVars, + + ncVersion, +}: +let + latestVersionForNc = { + "31" = latestVersionForNc."30"; + "30" = { + version = "7.5.2"; + appHash = "sha256-BfxJDCGsiRJrZWkNJSQF3rSFm/G3zzQn7C6DCETSzw4="; + srcHash = "sha256-imBO/64NW5MiozpufbMRcTI9WCaN8grnHlVo+fsUNlU="; + }; + }; + currentVersionInfo = + latestVersionForNc.${ncVersion} + or (throw "memories currently does not support nextcloud version ${ncVersion}"); + + commonMeta = with lib; { + homepage = "https://apps.nextcloud.com/apps/memories"; + changelog = "https://github.com/pulsejet/memories/blob/v${currentVersionInfo.version}/CHANGELOG.md"; + license = licenses.agpl3Only; + maintainers = with maintainers; [ SuperSandro2000 ]; + }; + + go-vod = buildGoModule rec { + pname = "go-vod"; + inherit (currentVersionInfo) version; + + src = fetchFromGitHub { + owner = "pulsejet"; + repo = "memories"; + tag = "v${version}"; + hash = currentVersionInfo.srcHash; + }; + + sourceRoot = "${src.name}/go-vod"; + + vendorHash = null; + + meta = commonMeta // { + description = "Extremely minimal on-demand video transcoding server in go"; + mainProgram = "go-vod"; + }; + }; +in +stdenv.mkDerivation rec { + pname = "nextcloud-app-memories"; + inherit (currentVersionInfo) version; + + src = fetchurl { + url = "https://github.com/pulsejet/memories/releases/download/v${version}/memories.tar.gz"; + hash = currentVersionInfo.appHash; + }; + + patches = [ + (replaceVars ./memories-paths.diff { + exiftool = lib.getExe exiftool; + ffmpeg = lib.getExe ffmpeg-headless; + ffprobe = lib.getExe' ffmpeg-headless "ffprobe"; + go-vod = lib.getExe go-vod; + }) + ]; + + postPatch = '' + rm appinfo/signature.json + rm -rf bin-ext/ + + substituteInPlace lib/Service/BinExt.php \ + --replace-fail "EXIFTOOL_VER = '12.70'" "EXIFTOOL_VER = '${exiftool.version}'" + ''; + + installPhase = '' + mkdir -p $out + cp -r ./* $out/ + ''; + + meta = commonMeta // { + description = "Fast, modern and advanced photo management suite"; + longDescription = '' + All settings related to required packages and installed programs are hardcoded in program code and cannot be changed. + ''; + }; +} diff --git a/pkgs/servers/nextcloud/packages/nextcloud-apps.json b/pkgs/servers/nextcloud/packages/nextcloud-apps.json index 7cda1b6008c1..fcd0f4a1114d 100644 --- a/pkgs/servers/nextcloud/packages/nextcloud-apps.json +++ b/pkgs/servers/nextcloud/packages/nextcloud-apps.json @@ -23,7 +23,6 @@ , "integration_paperless": "agpl3Plus" , "mail": "agpl3Plus" , "maps": "agpl3Plus" -, "memories": "agpl3Plus" , "music": "agpl3Plus" , "news": "agpl3Plus" , "nextpod": "agpl3Only" diff --git a/pkgs/servers/nextcloud/packages/thirdparty.nix b/pkgs/servers/nextcloud/packages/thirdparty.nix index 6ea612cf9ec6..1845947f9d7a 100644 --- a/pkgs/servers/nextcloud/packages/thirdparty.nix +++ b/pkgs/servers/nextcloud/packages/thirdparty.nix @@ -5,10 +5,11 @@ _: apps = apps.extend ( self: super: { - hmr_enabler = callPackage ./apps/hmr_enabler.nix { }; - recognize = callPackage ./apps/recognize.nix { inherit ncVersion; }; + memories = callPackage ./apps/memories.nix { inherit ncVersion; }; + + recognize = callPackage ./apps/recognize.nix { inherit ncVersion; }; } ); }