2024-06-04 18:11:41 -04:00
|
|
|
{
|
|
|
|
lib,
|
2025-04-10 12:52:55 +02:00
|
|
|
stdenv,
|
|
|
|
|
|
|
|
fetchFromGitHub,
|
2024-06-04 18:11:41 -04:00
|
|
|
makeDesktopItem,
|
2025-04-10 12:52:55 +02:00
|
|
|
|
|
|
|
copyDesktopItems,
|
2024-06-04 18:11:41 -04:00
|
|
|
makeWrapper,
|
2025-04-10 12:52:55 +02:00
|
|
|
nodejs,
|
|
|
|
yarn-berry_4,
|
|
|
|
zip,
|
|
|
|
|
|
|
|
electron,
|
|
|
|
commandLineArgs ? "",
|
2024-06-04 18:11:41 -04:00
|
|
|
}:
|
2025-04-10 12:52:55 +02:00
|
|
|
|
|
|
|
let
|
|
|
|
yarn-berry = yarn-berry_4;
|
|
|
|
in
|
2024-06-04 18:11:41 -04:00
|
|
|
stdenv.mkDerivation (finalAttrs: {
|
|
|
|
pname = "ytmdesktop";
|
2025-03-20 09:18:42 +00:00
|
|
|
version = "2.0.8";
|
2024-06-04 18:11:41 -04:00
|
|
|
|
2025-04-10 12:52:55 +02:00
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "ytmdesktop";
|
|
|
|
repo = "ytmdesktop";
|
|
|
|
tag = "v${finalAttrs.version}";
|
|
|
|
leaveDotGit = true;
|
|
|
|
|
|
|
|
postFetch = ''
|
|
|
|
cd $out
|
|
|
|
git rev-parse HEAD > .COMMIT
|
|
|
|
find -name .git -print0 | xargs -0 rm -rf
|
|
|
|
'';
|
|
|
|
|
|
|
|
hash = "sha256-QiV7U7LoJWvBqjVm7oVfHIiyw10cLSAk4lCQGO8hXtY=";
|
|
|
|
};
|
|
|
|
|
|
|
|
patches = [
|
2025-06-02 15:54:57 +02:00
|
|
|
# instead of running git during the build process
|
2025-04-10 12:52:55 +02:00
|
|
|
# use the .COMMIT file generated in the fetcher FOD
|
|
|
|
./git-rev-parse.patch
|
2024-07-11 13:00:47 +02:00
|
|
|
];
|
2024-06-04 18:11:41 -04:00
|
|
|
|
2025-04-10 12:52:55 +02:00
|
|
|
postPatch = lib.optionalString stdenv.hostPlatform.isLinux ''
|
|
|
|
substituteInPlace viteconfig/main.ts
|
|
|
|
|
|
|
|
# workaround for https://github.com/electron/electron/issues/31121
|
|
|
|
substituteInPlace src/main/index.ts \
|
|
|
|
--replace-fail "process.resourcesPath" "'$out/share/ytmdesktop/resources'"
|
|
|
|
'';
|
|
|
|
|
|
|
|
missingHashes = ./missing-hashes.json;
|
|
|
|
|
|
|
|
yarnOfflineCache = yarn-berry.fetchYarnBerryDeps {
|
|
|
|
inherit (finalAttrs) src missingHashes;
|
|
|
|
hash = "sha256-piHpm7eeOoDmpgc1SmeJ3wLZHZiUZZGu+Pl30qQYqps=";
|
|
|
|
};
|
|
|
|
|
2024-06-04 18:11:41 -04:00
|
|
|
nativeBuildInputs = [
|
|
|
|
copyDesktopItems
|
|
|
|
makeWrapper
|
2025-04-10 12:52:55 +02:00
|
|
|
nodejs
|
|
|
|
yarn-berry
|
|
|
|
yarn-berry.yarnBerryConfigHook
|
|
|
|
zip
|
2024-06-04 18:11:41 -04:00
|
|
|
];
|
|
|
|
|
2025-04-10 12:52:55 +02:00
|
|
|
# Don't auto-run scripts of dependencies
|
|
|
|
# We don't need any native modules, so this is fine
|
|
|
|
env.YARN_ENABLE_SCRIPTS = "0";
|
2024-06-04 18:11:41 -04:00
|
|
|
|
2025-04-10 12:52:55 +02:00
|
|
|
buildPhase = ''
|
|
|
|
runHook preBuild
|
2024-06-04 18:11:41 -04:00
|
|
|
|
2025-04-10 12:52:55 +02:00
|
|
|
cp -r ${electron.dist} electron-dist
|
|
|
|
chmod -R u+w electron-dist
|
2024-06-04 18:11:41 -04:00
|
|
|
|
2025-04-10 12:52:55 +02:00
|
|
|
pushd electron-dist
|
|
|
|
zip -0Xqr ../electron.zip .
|
|
|
|
popd
|
2024-06-04 18:11:41 -04:00
|
|
|
|
2025-04-10 12:52:55 +02:00
|
|
|
rm -r electron-dist
|
2024-06-04 18:11:41 -04:00
|
|
|
|
2025-04-10 12:52:55 +02:00
|
|
|
# force @electron/packager to use our electron instead of downloading it
|
|
|
|
substituteInPlace node_modules/@electron/packager/dist/packager.js \
|
|
|
|
--replace-fail 'await this.getElectronZipPath(downloadOpts)' '"electron.zip"'
|
2024-06-04 18:11:41 -04:00
|
|
|
|
2025-04-10 12:52:55 +02:00
|
|
|
yarn run package
|
2024-06-04 18:11:41 -04:00
|
|
|
|
2025-04-10 12:52:55 +02:00
|
|
|
runHook postBuild
|
2024-06-04 18:11:41 -04:00
|
|
|
'';
|
|
|
|
|
2025-04-10 12:52:55 +02:00
|
|
|
installPhase =
|
|
|
|
''
|
|
|
|
runHook preInstall
|
|
|
|
''
|
|
|
|
+ lib.optionalString stdenv.hostPlatform.isLinux ''
|
2024-06-04 18:11:41 -04:00
|
|
|
|
2025-04-10 12:52:55 +02:00
|
|
|
mkdir -p "$out"/share/ytmdesktop
|
|
|
|
cp -r out/*/{locales,resources{,.pak}} "$out"/share/ytmdesktop
|
2024-06-04 18:11:41 -04:00
|
|
|
|
2025-04-10 12:52:55 +02:00
|
|
|
install -Dm644 src/assets/icons/ytmd.png "$out"/share/pixmaps/ytmdesktop.png
|
2024-06-04 18:11:41 -04:00
|
|
|
|
2025-04-10 12:52:55 +02:00
|
|
|
makeWrapper ${lib.getExe electron} "$out"/bin/ytmdesktop \
|
|
|
|
--add-flags "$out"/share/ytmdesktop/resources/app.asar \
|
|
|
|
--add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--ozone-platform-hint=auto --enable-features=WaylandWindowDecorations --enable-wayland-ime=true}}" \
|
|
|
|
--add-flags ${lib.escapeShellArg commandLineArgs}
|
|
|
|
''
|
|
|
|
+ lib.optionalString stdenv.hostPlatform.isDarwin ''
|
|
|
|
mkdir -p $out/Applications
|
|
|
|
cp -r out/*/"YouTube Music Desktop App".app "$out"/Applications
|
2024-06-04 18:11:41 -04:00
|
|
|
|
2025-04-10 12:52:55 +02:00
|
|
|
wrapProgram "$out"/Applications/"YouTube Music Desktop App".app/Contents/MacOS/youtube-music-desktop-app \
|
|
|
|
--add-flags ${lib.escapeShellArg commandLineArgs}
|
2024-06-04 18:11:41 -04:00
|
|
|
|
2025-04-10 12:52:55 +02:00
|
|
|
makeWrapper "$out"/Applications/"YouTube Music Desktop App".app/Contents/MacOS/youtube-music-desktop-app "$out"/bin/ytmdesktop
|
|
|
|
''
|
|
|
|
+ ''
|
|
|
|
runHook postInstall
|
|
|
|
'';
|
2024-06-04 18:11:41 -04:00
|
|
|
|
2025-04-10 12:52:55 +02:00
|
|
|
desktopItems = [
|
|
|
|
(makeDesktopItem {
|
|
|
|
desktopName = "YouTube Music Desktop App";
|
|
|
|
exec = "ytmdesktop";
|
|
|
|
icon = "ytmdesktop";
|
|
|
|
name = "ytmdesktop";
|
|
|
|
genericName = finalAttrs.meta.description;
|
|
|
|
mimeTypes = [ "x-scheme-handler/ytmd" ];
|
|
|
|
categories = [
|
|
|
|
"AudioVideo"
|
|
|
|
"Audio"
|
|
|
|
];
|
|
|
|
startupNotify = true;
|
|
|
|
startupWMClass = "YouTube Music Desktop App";
|
|
|
|
})
|
|
|
|
];
|
2024-06-04 18:11:41 -04:00
|
|
|
|
|
|
|
meta = {
|
|
|
|
changelog = "https://github.com/ytmdesktop/ytmdesktop/tag/v${finalAttrs.version}";
|
|
|
|
description = "A Desktop App for YouTube Music";
|
|
|
|
downloadPage = "https://github.com/ytmdesktop/ytmdesktop/releases";
|
|
|
|
homepage = "https://ytmdesktop.app/";
|
|
|
|
license = lib.licenses.gpl3Only;
|
2025-03-06 21:49:37 +01:00
|
|
|
mainProgram = "ytmdesktop";
|
2024-06-04 18:11:41 -04:00
|
|
|
maintainers = [ lib.maintainers.cjshearer ];
|
2025-04-10 12:52:55 +02:00
|
|
|
inherit (electron.meta) platforms;
|
2024-06-04 18:11:41 -04:00
|
|
|
};
|
|
|
|
})
|