youtube-music: 2.1.0 -> 3.1.0

This commit is contained in:
Alexandre Acebedo 2023-12-13 23:18:38 +01:00
parent f46e0f051c
commit c747c62364
No known key found for this signature in database
GPG Key ID: D67F8E1727372E67

View File

@ -2,45 +2,89 @@
, fetchFromGitHub , fetchFromGitHub
, buildNpmPackage , buildNpmPackage
, makeWrapper , makeWrapper
, electron_25 , electron
, python3 , python3
, stdenv , stdenv
, stdenvNoCC
, copyDesktopItems , copyDesktopItems
, moreutils
, cacert
, jq
, nodePackages
, makeDesktopItem , makeDesktopItem
}: }:
let let
pname = "youtube-music"; pname = "youtube-music";
version = "2.1.0"; version = "3.1.0";
src = fetchFromGitHub { src = fetchFromGitHub {
owner = "th-ch"; owner = "th-ch";
repo = pname; repo = pname;
rev = "v${version}"; rev = "v${version}";
hash = "sha256-aYEEUv+dybzcH0aNJlZ19XF++8cswFunrU0H+ZaKm4Y="; hash = "sha256-6ZiftpdCwxCkJzcHryVrUKzM+mM1eQpdLNFl0Dja59Q=";
}; };
electron = electron_25;
in in
buildNpmPackage { stdenv.mkDerivation (finalAttrs: {
inherit pname version src; inherit pname version src;
nativeBuildInputs = [ makeWrapper python3 ] pnpmDeps = stdenvNoCC.mkDerivation {
pname = "${finalAttrs.pname}-pnpm-deps";
inherit (finalAttrs) src version ELECTRON_SKIP_BINARY_DOWNLOAD;
nativeBuildInputs = [ jq moreutils nodePackages.pnpm cacert ];
installPhase = ''
export HOME=$(mktemp -d)
pnpm config set store-dir $out
pnpm install --frozen-lockfile --ignore-script
rm -rf $out/v3/tmp
for f in $(find $out -name "*.json"); do
sed -i -E -e 's/"checkedAt":[0-9]+,//g' $f
jq --sort-keys . $f | sponge $f
done
'';
dontBuild = true;
dontFixup = true;
outputHashMode = "recursive";
outputHashAlgo = "sha256";
outputHash = {
x86_64-linux = "sha256-Oy11V7FXfVhLUR9gX0sjQEFuVPFpbaVdT518oOSLcvA=";
aarch64-linux = "sha256-6nXemaGiQjp2stjjKItPJ62VcH5Q5pRf63qKtl2haXI=";
x86_64-darwin = "sha256-jSMAw+AMD63vqPckZjblw4EDngA4E8h0WlsZu3hUShY=";
aarch64-darwin = "sha256-zujXURpIcw7IOw63AW167h6cywYXydhHZMzA2apGZAs=";
}.${stdenv.system} or (throw "Unsupported platform");
};
nativeBuildInputs =
[ makeWrapper python3 nodePackages.pnpm nodePackages.nodejs ]
++ lib.optionals (!stdenv.isDarwin) [ copyDesktopItems ]; ++ lib.optionals (!stdenv.isDarwin) [ copyDesktopItems ];
npmDepsHash = "sha256-XGV0mTywYYxpMitojzIILB/Eu/8dfk/aCvUxIkx4SDQ=";
makeCacheWritable = true;
env = { ELECTRON_SKIP_BINARY_DOWNLOAD = 1;
ELECTRON_SKIP_BINARY_DOWNLOAD = 1;
}; preBuild = ''
export HOME=$(mktemp -d)
export STORE_PATH=$(mktemp -d)
cp -Tr "$pnpmDeps" "$STORE_PATH"
chmod -R +w "$STORE_PATH"
pnpm config set store-dir "$STORE_PATH"
pnpm install --offline --frozen-lockfile --ignore-script
patchShebangs node_modules/{*,.*}
'';
postBuild = lib.optionalString stdenv.isDarwin '' postBuild = lib.optionalString stdenv.isDarwin ''
cp -R ${electron}/Applications/Electron.app Electron.app cp -R ${electron}/Applications/Electron.app Electron.app
chmod -R u+w Electron.app chmod -R u+w Electron.app
'' + '' '' + ''
npm exec electron-builder -- \ pnpm build
./node_modules/.bin/electron-builder \
--dir \ --dir \
-c.electronDist=${if stdenv.isDarwin then "." else "${electron}/libexec/electron"} \ -c.electronDist=${if stdenv.isDarwin then "." else "${electron}/libexec/electron"} \
-c.electronVersion=${electron.version} -c.electronVersion=${electron.version}
@ -83,7 +127,7 @@ buildNpmPackage {
icon = "youtube-music"; icon = "youtube-music";
desktopName = "Youtube Music"; desktopName = "Youtube Music";
startupWMClass = "Youtube Music"; startupWMClass = "Youtube Music";
categories = ["AudioVideo"]; categories = [ "AudioVideo" ];
}) })
]; ];
@ -93,6 +137,6 @@ buildNpmPackage {
license = licenses.mit; license = licenses.mit;
maintainers = [ maintainers.aacebedo ]; maintainers = [ maintainers.aacebedo ];
mainProgram = "youtube-music"; mainProgram = "youtube-music";
platforms = platforms.all; platforms = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];
}; };
} })