From 2beaf5e5a6afa53b2f8a1943ff2bb17024ca8e24 Mon Sep 17 00:00:00 2001 From: Alexis Hildebrandt Date: Sat, 1 Mar 2025 05:34:24 +0100 Subject: [PATCH] quba: Add support for darwin --- pkgs/by-name/qu/quba/package.nix | 71 +++++++++++++++++++++++--------- 1 file changed, 51 insertions(+), 20 deletions(-) diff --git a/pkgs/by-name/qu/quba/package.nix b/pkgs/by-name/qu/quba/package.nix index 1be9b1a481a7..18e95f6bc801 100644 --- a/pkgs/by-name/qu/quba/package.nix +++ b/pkgs/by-name/qu/quba/package.nix @@ -1,29 +1,14 @@ { lib, + stdenvNoCC, appimageTools, fetchurl, + _7zz, }: let - version = "1.4.2"; pname = "quba"; - - src = fetchurl { - url = "https://github.com/ZUGFeRD/quba-viewer/releases/download/v${version}/Quba-${version}.AppImage"; - hash = "sha256-3goMWN5GeQaLJimUKbjozJY/zJmqc9Mvy2+6bVSt1p0="; - }; - - appimageContents = appimageTools.extractType1 { inherit pname version src; }; -in -appimageTools.wrapType1 { - inherit pname version src; - - extraInstallCommands = '' - install -m 444 -D ${appimageContents}/${pname}.desktop -t $out/share/applications - substituteInPlace $out/share/applications/${pname}.desktop \ - --replace-fail 'Exec=AppRun' 'Exec=${pname}' - cp -r ${appimageContents}/usr/share/icons $out/share - ''; + version = "1.4.2"; meta = { description = "Viewer for electronic invoices"; @@ -32,6 +17,52 @@ appimageTools.wrapType1 { license = lib.licenses.asl20; sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ]; maintainers = with lib.maintainers; [ onny ]; - platforms = [ "x86_64-linux" ]; + platforms = [ "x86_64-linux" ] ++ lib.platforms.darwin; }; -} + + src = fetchurl { + url = "https://github.com/ZUGFeRD/quba-viewer/releases/download/v${version}/Quba-${version}.AppImage"; + hash = "sha256-3goMWN5GeQaLJimUKbjozJY/zJmqc9Mvy2+6bVSt1p0="; + }; + + appimageContents = appimageTools.extractType1 { inherit pname version src; }; + + linux = appimageTools.wrapType1 { + inherit + pname + version + src + meta + ; + + extraInstallCommands = '' + install -m 444 -D ${appimageContents}/quba.desktop -t $out/share/applications + substituteInPlace $out/share/applications/quba.desktop \ + --replace-fail 'Exec=AppRun' 'Exec=quba' + cp -r ${appimageContents}/usr/share/icons $out/share + ''; + }; + + darwin = stdenvNoCC.mkDerivation { + inherit pname version meta; + + src = fetchurl { + url = "https://github.com/ZUGFeRD/quba-viewer/releases/download/v${version}/Quba-${version}-universal.dmg"; + hash = "sha256-q7va2D9AT0BoPhfkub/RFQxGyF12uFaCDpSYIxslqMc="; + }; + + unpackCmd = "7zz x -bd -osource -xr'!*/Applications' -xr'!*com.apple.provenance' $curSrc"; + + nativeBuildInputs = [ _7zz ]; + + installPhase = '' + runHook preInstall + + mkdir -p $out/Applications + mv Quba.app $out/Applications + + runHook postInstall + ''; + }; +in +if stdenvNoCC.hostPlatform.isLinux then linux else darwin