From 876e51ec60933bf4bba015e9b82277a4e31b55a3 Mon Sep 17 00:00:00 2001 From: Aiden Schembri Date: Wed, 29 Apr 2026 08:40:03 +0200 Subject: [PATCH] fladder: add darwin support --- pkgs/by-name/fl/fladder/package.nix | 172 +++++++++++++++++----------- 1 file changed, 104 insertions(+), 68 deletions(-) diff --git a/pkgs/by-name/fl/fladder/package.nix b/pkgs/by-name/fl/fladder/package.nix index f5fd73a3a53e..60b60a7ee6a7 100644 --- a/pkgs/by-name/fl/fladder/package.nix +++ b/pkgs/by-name/fl/fladder/package.nix @@ -1,9 +1,13 @@ { lib, + stdenv, + fetchurl, fetchFromGitHub, flutter335, copyDesktopItems, makeDesktopItem, + undmg, + makeBinaryWrapper, alsa-lib, libdisplay-info, @@ -18,82 +22,114 @@ let flutter = flutter335; -in + sourceBuild = flutter.buildFlutterApplication (finalAttrs: { + pname = "fladder"; + version = "0.10.3"; -flutter.buildFlutterApplication (finalAttrs: { - pname = "fladder"; - version = "0.10.3"; + src = fetchFromGitHub { + owner = "DonutWare"; + repo = "Fladder"; + tag = "v${finalAttrs.version}"; + hash = "sha256-0eFHylRi2UVaKRG7K3tDZVscgoiL5xFrtFhZiJxj4Mk="; + }; - src = fetchFromGitHub { - owner = "DonutWare"; - repo = "Fladder"; - tag = "v${finalAttrs.version}"; - hash = "sha256-0eFHylRi2UVaKRG7K3tDZVscgoiL5xFrtFhZiJxj4Mk="; - }; + inherit targetFlutterPlatform; - inherit targetFlutterPlatform; + pubspecLock = lib.importJSON ./pubspec.lock.json; - pubspecLock = lib.importJSON ./pubspec.lock.json; + gitHashes = lib.importJSON ./git-hashes.json; - gitHashes = lib.importJSON ./git-hashes.json; + nativeBuildInputs = lib.optionals (targetFlutterPlatform == "linux") [ + copyDesktopItems + ]; - nativeBuildInputs = lib.optionals (targetFlutterPlatform == "linux") [ - copyDesktopItems - ]; + buildInputs = [ + alsa-lib + libdisplay-info + mpv-unwrapped + libxpresent + libxscrnsaver + ] + ++ lib.optionals (targetFlutterPlatform == "linux") [ + libepoxy + ]; - buildInputs = [ - alsa-lib - libdisplay-info - mpv-unwrapped - libxpresent - libxscrnsaver - ] - ++ lib.optionals (targetFlutterPlatform == "linux") [ - libepoxy - ]; + postInstall = + lib.optionalString (targetFlutterPlatform == "web") ( + '' + sed -i 's;base href="/";base href="$out";' $out/index.html + '' + + lib.optionalString (baseUrl != null) '' + echo '{"baseUrl": "${baseUrl}"}' > $out/assets/config/config.json + '' + ) + + lib.optionalString (targetFlutterPlatform == "linux") '' + # Install SVG icon + install -Dm644 icons/fladder_icon.svg \ + $out/share/icons/hicolor/scalable/apps/fladder.svg + ''; - postInstall = - lib.optionalString (targetFlutterPlatform == "web") ( - '' - sed -i 's;base href="/";base href="$out";' $out/index.html - '' - + lib.optionalString (baseUrl != null) '' - echo '{"baseUrl": "${baseUrl}"}' > $out/assets/config/config.json - '' - ) - + lib.optionalString (targetFlutterPlatform == "linux") '' - # Install SVG icon - install -Dm644 icons/fladder_icon.svg \ - $out/share/icons/hicolor/scalable/apps/fladder.svg + desktopItems = lib.optionals (targetFlutterPlatform == "linux") [ + (makeDesktopItem { + name = "fladder"; + desktopName = "Fladder"; + genericName = "Jellyfin Client"; + exec = "Fladder"; + icon = "fladder"; + comment = "Simple Jellyfin Frontend built on top of Flutter"; + categories = [ + "AudioVideo" + "Video" + "Player" + ]; + }) + ]; + + passthru.updateScript = ./update.sh; + + meta = { + description = "Simple Jellyfin Frontend built on top of Flutter"; + homepage = "https://github.com/DonutWare/Fladder"; + downloadPage = "https://github.com/DonutWare/Fladder/releases"; + license = lib.licenses.gpl3Only; + maintainers = with lib.maintainers; [ + ratcornu + schembriaiden + ]; + mainProgram = "Fladder"; + }; + }); + + darwin = stdenv.mkDerivation { + pname = sourceBuild.pname; + inherit (sourceBuild) version; + + src = fetchurl { + url = "https://github.com/DonutWare/Fladder/releases/download/v${sourceBuild.version}/Fladder-macOS-${sourceBuild.version}.dmg"; + hash = "sha256-Vnz0jtmDptcrehE7DrgyTzFJJopirsLaO+lu1V/Xd+o="; + }; + + nativeBuildInputs = [ + undmg + makeBinaryWrapper + ]; + + sourceRoot = "."; + + installPhase = '' + runHook preInstall + + mkdir -p $out/Applications + cp -r Fladder.app $out/Applications + makeBinaryWrapper $out/Applications/Fladder.app/Contents/MacOS/Fladder $out/bin/Fladder + + runHook postInstall ''; - desktopItems = lib.optionals (targetFlutterPlatform == "linux") [ - (makeDesktopItem { - name = "fladder"; - desktopName = "Fladder"; - genericName = "Jellyfin Client"; - exec = "Fladder"; - icon = "fladder"; - comment = "Simple Jellyfin Frontend built on top of Flutter"; - categories = [ - "AudioVideo" - "Video" - "Player" - ]; - }) - ]; - - passthru.updateScript = ./update.sh; - - meta = { - description = "Simple Jellyfin Frontend built on top of Flutter"; - homepage = "https://github.com/DonutWare/Fladder"; - downloadPage = "https://github.com/DonutWare/Fladder/releases"; - license = lib.licenses.gpl3Only; - maintainers = with lib.maintainers; [ - ratcornu - schembriaiden - ]; - mainProgram = "Fladder"; + meta = sourceBuild.meta // { + sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ]; + platforms = lib.platforms.darwin; + }; }; -}) +in +if stdenv.hostPlatform.isDarwin then darwin else sourceBuild