Unverified Commit c89ed11b authored by isabel's avatar isabel Committed by GitHub
Browse files

plezy: 1.17.0 -> 1.30.0; darwin support (#506695)

parents bca5b04a f8afe166
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
{
  "os_media_controls": "sha256-6aM7C9KuF7we//yMUQ0SZ8o+5KQ9EP5sjkzwdghM4EQ=",
  "auto_updater": "sha256-787cMkeT2BlfwVcy4y46XkWioNqLKJgQ/CCxQvERa+A=",
  "auto_updater_macos": "sha256-787cMkeT2BlfwVcy4y46XkWioNqLKJgQ/CCxQvERa+A=",
  "auto_updater_platform_interface": "sha256-787cMkeT2BlfwVcy4y46XkWioNqLKJgQ/CCxQvERa+A=",
  "auto_updater_windows": "sha256-787cMkeT2BlfwVcy4y46XkWioNqLKJgQ/CCxQvERa+A=",
  "material_symbols_icons": "sha256-XRB6AZ4Q33sQKVZFA8lgdXCW/bx55h/RpmuItmFYVJM=",
  "os_media_controls": "sha256-kSJov92pvzFQGIKnQb6XlwRXTY0Xs4iOZmc/390yf0c=",
  "wakelock_plus": "sha256-OOTRP8v5mUma3j+G+koWoAufxrynWFMMhCLecvd1MhE="
}
+122 −88
Original line number Diff line number Diff line
{
  lib,
  stdenv,
  stdenvNoCC,
  flutter338,
  fetchFromGitHub,
  yq-go,
  fetchurl,
  pkg-config,
  libsecret,
  jsoncpp,
@@ -10,27 +12,60 @@
  libass,
  keybinder3,
  ffmpeg,
  sdl3,
  zlib,
  libevdev,
  jdk,
  makeDesktopItem,
  copyDesktopItems,
  imagemagick,
  _experimental-update-script-combinators,
  nix-update-script,
  _7zz,
  makeBinaryWrapper,
  runCommand,
  dart,
}:

flutter338.buildFlutterApplication rec {
let
  pname = "plezy";
  version = "1.17.0";
  version = "1.30.0";

  src = fetchFromGitHub {
    owner = "edde746";
    repo = "plezy";
    tag = version;
    hash = "sha256-bJ/Qho6hkjbGOFUJj3J4XKk4Eq+3PU1VFGxik5ht16c=";
    hash = "sha256-9bB9L9f2s0i2xF4JIe4vlEpt/bmF1gf3gxcoHdCrYqc=";
  };

  simdutf = fetchurl {
    url = "https://github.com/simdutf/simdutf/releases/download/v6.4.2/singleheader.zip";
    hash = "sha256-n+TW9RVySlXI3oj+5EY+CJChq+ImfNoTxLXSRdWAOeY=";
  };

  zlib-root = runCommand "zlib-root" { } ''
    mkdir $out
    ln -s ${zlib.dev}/include $out/include
    ln -s ${zlib}/lib $out/lib
  '';

  meta = {
    description = "Modern cross-platform Plex client built with Flutter";
    homepage = "https://github.com/edde746/plezy";
    mainProgram = "plezy";
    license = lib.licenses.gpl3Only;
    maintainers = with lib.maintainers; [
      mio
      miniharinn
    ];
    platforms = lib.platforms.linux ++ [
      "x86_64-darwin"
      "aarch64-darwin"
    ];
    sourceProvenance = lib.optionals stdenv.hostPlatform.isDarwin (
      with lib.sourceTypes; [ binaryNativeCode ]
    );
  };

  linux = flutter338.buildFlutterApplication rec {
    inherit pname version src;

    pubspecLock = lib.importJSON ./pubspec.lock.json;

    gitHashes = lib.importJSON ./git-hashes.json;
@@ -48,14 +83,20 @@ flutter338.buildFlutterApplication rec {
      libass
      keybinder3
      ffmpeg
    sdl3
      zlib
      libevdev
      jdk
    ];

    env = {
      ZLIB_ROOT = zlib-root;
      JAVA_HOME = "${jdk}/lib/openjdk";
    };

    postPatch = ''
    # Avoid FetchContent download of SDL3 during build.
      substituteInPlace linux/CMakeLists.txt \
      --replace-fail "set(BUNDLE_SDL3 ON CACHE BOOL \"\" FORCE)" \
                     "set(BUNDLE_SDL3 OFF CACHE BOOL \"\" FORCE)"
        --replace-fail "URL https://github.com/simdutf/simdutf/releases/download/v6.4.2/singleheader.zip" \
                       "URL file://${simdutf}"
    '';

    desktopItems = [
@@ -64,7 +105,7 @@ flutter338.buildFlutterApplication rec {
        exec = "plezy";
        icon = "plezy";
        desktopName = "Plezy";
      comment = "Modern cross-platform Plex client built with Flutter";
        comment = meta.description;
        categories = [
          "AudioVideo"
          "Video"
@@ -81,46 +122,39 @@ flutter338.buildFlutterApplication rec {
      done
    '';

  passthru = {
    pubspecSource =
      runCommand "pubspec.lock.json"
        {
          inherit src;
          nativeBuildInputs = [ yq-go ];
        }
        ''
          yq eval --output-format=json --prettyPrint $src/pubspec.lock > "$out"
        '';
    updateScript = _experimental-update-script-combinators.sequence [
      (nix-update-script { })
      (
        (_experimental-update-script-combinators.copyAttrOutputToFile "plezy.pubspecSource" ./pubspec.lock.json)
        // {
          supportedFeatures = [ ];
        }
      )
      {
        command = [
          dart.fetchGitHashesScript
          "--input"
          ./pubspec.lock.json
          "--output"
          ./git-hashes.json
        ];
        supportedFeatures = [ ];
      }
    ];
    passthru.updateScript = ./update.sh;

    inherit meta;
  };

  meta = {
    description = "Modern cross-platform Plex client built with Flutter";
    homepage = "https://github.com/edde746/plezy";
    mainProgram = "plezy";
    license = lib.licenses.gpl3Only;
    maintainers = with lib.maintainers; [
      mio
      miniharinn
  darwin = stdenvNoCC.mkDerivation {
    inherit pname version;

    passthru.updateScript = ./update.sh;

    src = fetchurl {
      url = "https://github.com/edde746/plezy/releases/download/${version}/plezy-macos.dmg";
      hash = "sha256-a3LvwWZvLPD7yKKbC+oYXSgoHXUS+mOojzfDyW7/QOE=";
    };

    nativeBuildInputs = [
      _7zz
      makeBinaryWrapper
    ];
    platforms = lib.platforms.linux;

    sourceRoot = "Plezy.app";

    installPhase = ''
      runHook preInstall

      mkdir -p $out/Applications/Plezy.app
      cp -r . $out/Applications/Plezy.app
      makeBinaryWrapper $out/Applications/Plezy.app/Contents/MacOS/Plezy $out/bin/plezy

      runHook postInstall
    '';

    inherit meta;
  };
}
in
if stdenv.hostPlatform.isDarwin then darwin else linux
+249 −264

File changed.

Preview size limit exceeded, changes collapsed.

+34 −0
Original line number Diff line number Diff line
#!/usr/bin/env nix-shell
#! nix-shell -I nixpkgs=./. -i bash -p curl gnused jq nix nix-prefetch-git python3 yq-go

set -eou pipefail

ROOT="$(dirname "$(readlink -f "$0")")"

latestVersion=$(curl --fail --silent https://api.github.com/repos/edde746/plezy/releases/latest | jq --raw-output .tag_name)

currentVersion=$(nix-instantiate --eval -E "with import ./. {}; plezy.version" | tr -d '"')

if [[ "$currentVersion" == "$latestVersion" ]]; then
  echo "plezy is up-to-date: $currentVersion"
  exit 0
fi

echo "updating plezy: $currentVersion -> $latestVersion"

sed -i "s/version = \".*\"/version = \"${latestVersion}\"/" "$ROOT/package.nix"

GIT_SRC_URL="https://github.com/edde746/plezy/archive/refs/tags/${latestVersion}.tar.gz"
GIT_SRC_SHA=$(nix --extra-experimental-features nix-command hash to-sri --type sha256 "$(nix-prefetch-url --unpack "$GIT_SRC_URL")")
sed -i "/fetchFromGitHub/,/hash/{s|hash = \".*\"|hash = \"${GIT_SRC_SHA}\"|}" "$ROOT/package.nix"

DMG_URL="https://github.com/edde746/plezy/releases/download/${latestVersion}/plezy-macos.dmg"
DMG_SHA=$(nix --extra-experimental-features nix-command hash to-sri --type sha256 "$(nix-prefetch-url "$DMG_URL")")
sed -i "/plezy-macos.dmg/,/hash/{s|hash = \".*\"|hash = \"${DMG_SHA}\"|}" "$ROOT/package.nix"

curl --fail --silent "https://raw.githubusercontent.com/edde746/plezy/${latestVersion}/pubspec.lock" \
  | yq eval --output-format=json --prettyPrint > "$ROOT/pubspec.lock.json"

python3 "$(dirname "$(readlink -f "$0")")/../../../development/compilers/dart/fetch-git-hashes.py" \
  --input "$ROOT/pubspec.lock.json" \
  --output "$ROOT/git-hashes.json"