From f442c0ab52958c07540c14d7a3fdcc15980d0a97 Mon Sep 17 00:00:00 2001 From: Yury Shvedov Date: Sun, 25 Aug 2024 19:40:19 +0300 Subject: [PATCH] yandex-music: init at 5.13.2 Yandex Music - Personal recommendations, selections for any occasion and new music. This is repacked version of Beta of Yandex Music version for windows desktop based on electron. The repack process is developing at [cucumber-sp's](https://github.com/cucumber-sp/yandex-music-linux) project. Change-Id: I517ba94ceee04cf9f1e13d7c33d5355cbcec0939 --- pkgs/by-name/ya/yandex-music/info.json | 7 ++ pkgs/by-name/ya/yandex-music/package.nix | 88 +++++++++++++++++++++++ pkgs/by-name/ya/yandex-music/update.sh | 43 +++++++++++ pkgs/by-name/ya/yandex-music/ym_info.json | 14 ++++ 4 files changed, 152 insertions(+) create mode 100644 pkgs/by-name/ya/yandex-music/info.json create mode 100644 pkgs/by-name/ya/yandex-music/package.nix create mode 100755 pkgs/by-name/ya/yandex-music/update.sh create mode 100644 pkgs/by-name/ya/yandex-music/ym_info.json diff --git a/pkgs/by-name/ya/yandex-music/info.json b/pkgs/by-name/ya/yandex-music/info.json new file mode 100644 index 000000000000..809ec521526a --- /dev/null +++ b/pkgs/by-name/ya/yandex-music/info.json @@ -0,0 +1,7 @@ +{ + "branch": "master", + "commit_hash": "4ac238a00ca0b36e9755e55e54a22d3107ba443c", + "commit_message": "Update packages", + "date": "2024-08-27", + "tag": "v5.13.2" +} diff --git a/pkgs/by-name/ya/yandex-music/package.nix b/pkgs/by-name/ya/yandex-music/package.nix new file mode 100644 index 000000000000..581bea890456 --- /dev/null +++ b/pkgs/by-name/ya/yandex-music/package.nix @@ -0,0 +1,88 @@ +{ + fetchurl, + stdenvNoCC, + lib, + makeWrapper, + p7zip, + asar, + jq, + python3, + electron, + fetchFromGitHub, + electronArguments ? "", + trayEnabled ? true, +}: +stdenvNoCC.mkDerivation rec { + pname = "yandex-music"; + version = "5.13.2"; + + src = fetchFromGitHub { + owner = "cucumber-sp"; + repo = "yandex-music-linux"; + rev = "v${version}"; + hash = "sha256-yQX2GEulAQ02BndpwAAwGdTYtUlNXCgsCUdmXxPwtKU="; + }; + + nativeBuildInputs = [ + p7zip + asar + jq + python3 + makeWrapper + ]; + + passthru.updateScript = ./update.sh; + + ymExe = + let + ym_info = builtins.fromJSON (builtins.readFile ./ym_info.json); + in + fetchurl { + url = ym_info.ym.exe_link; + sha256 = ym_info.ym.exe_sha256; + }; + + buildPhase = '' + runHook preBuild + bash "./repack.sh" -o "./app" "$ymExe" + runHook postBuild + ''; + + installPhase = '' + runHook preInstall + + mkdir -p "$out/share/nodejs" + mv app/yandex-music.asar "$out/share/nodejs" + + CONFIG_FILE="$out/share/yandex-music.conf" + echo "TRAY_ENABLED=${if trayEnabled then "1" else "0"}" >> "$CONFIG_FILE" + echo "ELECTRON_ARGS=\"${electronArguments}\"" >> "$CONFIG_FILE" + + + install -Dm755 "$src/templates/yandex-music.sh" "$out/bin/yandex-music" + substituteInPlace "$out/bin/yandex-music" \ + --replace-fail "%electron_path%" "${electron}/bin/electron" \ + --replace-fail "%asar_path%" "$out/share/nodejs/yandex-music.asar" + + wrapProgram "$out/bin/yandex-music" \ + --set-default YANDEX_MUSIC_CONFIG "$CONFIG_FILE" + + install -Dm644 "./app/favicon.png" "$out/share/pixmaps/yandex-music.png" + install -Dm644 "./app/favicon.png" "$out/share/icons/hicolor/48x48/apps/yandex-music.png" + install -Dm644 "./app/favicon.svg" "$out/share/icons/hicolor/scalable/apps/yandex-music.svg" + + install -Dm644 "$src/templates/desktop" "$out/share/applications/yandex-music.desktop" + + runHook postInstall + ''; + + meta = { + description = "Yandex Music - Personal recommendations, selections for any occasion and new music"; + homepage = "https://music.yandex.ru/"; + downloadPage = "https://music.yandex.ru/download/"; + changelog = "https://github.com/cucumber-sp/yandex-music-linux/releases/tag/v5.13.2"; + license = lib.licenses.unfree; + platforms = lib.platforms.linux; + maintainers = with lib.maintainers; [ shved ]; + }; +} diff --git a/pkgs/by-name/ya/yandex-music/update.sh b/pkgs/by-name/ya/yandex-music/update.sh new file mode 100755 index 000000000000..92ebdb8d8a2e --- /dev/null +++ b/pkgs/by-name/ya/yandex-music/update.sh @@ -0,0 +1,43 @@ +#!/usr/bin/env nix-shell +#! nix-shell -i bash -p common-updater-scripts fd jq + +set -eou pipefail + +OWNER="cucumber-sp" +REPO="yandex-music-linux" +URL="https://api.github.com/repos/$OWNER/$REPO" +RAW="https://raw.githubusercontent.com/$OWNER/$REPO" + +latest_release="$(curl --silent "$URL/releases/latest")" +latest_tag="$(curl --silent "$URL/tags?per_page=1")" +commit_hash="$(jq -r '.[0].commit.sha' <<<"$latest_tag")" +latest_commit="$(curl --silent "$URL/commits/$commit_hash"'')" +commit_message="$(jq -r '.commit.message' <<<"$latest_commit")" + +tag=$(jq -r '.tag_name' <<<"$latest_release") +# drop 'v' prefix +version="${tag#v}" + +branch=$(jq -r '.target_commitish' <<<"$latest_release") + +date=$(jq -r '.created_at' <<<"$latest_release") +# truncate time +date=${date%T*} + +# update version; otherwise fail +update-source-version yandex-music "$version" --ignore-same-hash + +# set yandex-music dir +dir="pkgs/by-name/ya/yandex-music" + +echo -e '{ + "branch": "'"$branch"'", + "commit_hash": "'"$commit_hash"'", + "commit_message": "'"$commit_message"'", + "date": "'"$date"'", + "tag": "'"$tag"'" +}' >"$dir/info.json" || echo "Please run the script in the root of the Nixpkgs repo" + +curl --silent "$RAW/$commit_hash/utility/version_info.json" |\ + jq . > "$dir/ym_info.json" ||\ + echo "Please run the script in the root of the Nixpkgs repo" diff --git a/pkgs/by-name/ya/yandex-music/ym_info.json b/pkgs/by-name/ya/yandex-music/ym_info.json new file mode 100644 index 000000000000..4a1609ca7119 --- /dev/null +++ b/pkgs/by-name/ya/yandex-music/ym_info.json @@ -0,0 +1,14 @@ +{ + "ym": { + "version": "5.13.2", + "exe_name": "Yandex_Music_x64_5.13.2.exe", + "exe_link": "https://music-desktop-application.s3.yandex.net/stable/Yandex_Music_x64_5.13.2.exe", + "exe_sha256": "ac7a489a59e074358559f544a26143ca81a6bdfa41481242f3419b76eaffdb0b" + }, + "electron": { + "version": "29.4.6", + "x64": "https://github.com/electron/electron/releases/download/v29.4.6/electron-v29.4.6-linux-x64.zip", + "armv7l": "https://github.com/electron/electron/releases/download/v29.4.6/electron-v29.4.6-linux-armv7l.zip", + "arm64": "https://github.com/electron/electron/releases/download/v29.4.6/electron-v29.4.6-linux-arm64.zip" + } +}