From bf60265e0cf5cdfc1d233fd2c5036398f59ae12e Mon Sep 17 00:00:00 2001
From: Weijia Wang <9713184+wegank@users.noreply.github.com>
Date: Sun, 1 Oct 2023 00:08:12 +0200
Subject: [PATCH] nomacs: 3.17.2206 -> 3.17.2285

---
 pkgs/applications/graphics/nomacs/default.nix | 32 ++++++++-----------
 1 file changed, 13 insertions(+), 19 deletions(-)

diff --git a/pkgs/applications/graphics/nomacs/default.nix b/pkgs/applications/graphics/nomacs/default.nix
index 7c909de9f84c..3169d5f0d4f1 100644
--- a/pkgs/applications/graphics/nomacs/default.nix
+++ b/pkgs/applications/graphics/nomacs/default.nix
@@ -1,10 +1,9 @@
-{ stdenv
-, lib
-, mkDerivation
+{ lib
+, stdenv
 , fetchFromGitHub
-, fetchpatch
 , cmake
 , pkg-config
+, wrapQtAppsHook
 
 , qtbase
 , qttools
@@ -18,32 +17,24 @@
 , quazip
 }:
 
-mkDerivation rec {
+stdenv.mkDerivation rec {
   pname = "nomacs";
-  version = "3.17.2206";
+  version = "3.17.2285";
 
   src = fetchFromGitHub {
     owner = "nomacs";
     repo = "nomacs";
     rev = version;
-    sha256 = "1bq7bv4p7w67172y893lvpk90d6fgdpnylynbj2kn8m2hs6khya4";
+    hash = "sha256-/K7LRPwNy2PG7tIGD0tiKnEOPZ491lxFRlgf4xWYtxs=";
   };
 
-  patches = [
-    # Add support for Quazip 1.x.
-    (fetchpatch {
-      url = "https://github.com/nomacs/nomacs/pull/576.patch";
-      sha256 = "11ryjvd9jbb0cqagai4a6980jfq8lrcbyw2d7z9yld1f42w9kbxm";
-      stripLen = 1;
-    })
-  ];
-
   setSourceRoot = ''
     sourceRoot=$(echo */ImageLounge)
   '';
 
   nativeBuildInputs = [cmake
-                       pkg-config];
+                       pkg-config
+                       wrapQtAppsHook];
 
   buildInputs = [qtbase
                  qttools
@@ -62,13 +53,16 @@ mkDerivation rec {
                 "-DENABLE_TRANSLATIONS=ON"
                 "-DUSE_SYSTEM_QUAZIP=ON"];
 
+  postInstall = lib.optionalString stdenv.isDarwin ''
+    mkdir -p $out/lib
+    mv $out/libnomacsCore.dylib $out/lib/libnomacsCore.dylib
+  '';
+
   meta = with lib; {
     homepage = "https://nomacs.org";
     description = "Qt-based image viewer";
     maintainers = with lib.maintainers; [ mindavi ];
     license = licenses.gpl3Plus;
     inherit (qtbase.meta) platforms;
-    # Broken on hydra since 2020-08-15: https://hydra.nixos.org/build/125495291 (bump from 3.16 to 3.17 prerelease)
-    broken = stdenv.isDarwin;
   };
 }