Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions pkgs/by-name/yt/ytmdesktop/git-rev-parse.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
diff --git a/viteconfig/main.ts b/viteconfig/main.ts
index ba6e2b6..d748d0a 100644
--- a/viteconfig/main.ts
+++ b/viteconfig/main.ts
@@ -3,7 +3,7 @@ import { defineConfig } from "vite";

let gitBranch: string = "";
try {
- gitBranch = execSync("git rev-parse --abbrev-ref HEAD").toString();
+ gitBranch = "???";
} catch (e) {
// User has likely downloaded from the YTM Desktop via the "Download ZIP".
// We don't plan to support this, but at least provide users with a bit of improved UX
diff --git a/viteconfig/renderer.ts b/viteconfig/renderer.ts
index b6531f6..321947a 100644
--- a/viteconfig/renderer.ts
+++ b/viteconfig/renderer.ts
@@ -6,8 +6,8 @@ import { execSync } from "node:child_process";
let gitBranch: string = "";
let gitCommitHash: string = "";
try {
- gitBranch = execSync("git rev-parse --abbrev-ref HEAD").toString();
- gitCommitHash = execSync("git rev-parse HEAD").toString();
+ gitBranch = "???";
+ gitCommitHash = execSync("cat .COMMIT").toString();
} catch (e) {
// User has likely downloaded from the YTM Desktop via the "Download ZIP".
// We don't plan to support this, but at least provide users with a bit of improved UX
45 changes: 45 additions & 0 deletions pkgs/by-name/yt/ytmdesktop/missing-hashes.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"@esbuild/aix-ppc64@npm:0.21.5": "1f48fea96ab4fbc2921756361bc8a0c4d0690f14dc2298a357aa3d436bcd1cd646d490e5d71c4e0fb46b9e04401bc93153d6886456dd0665b6758be643c95a16",
"@esbuild/android-arm64@npm:0.21.5": "7a4831b0886c165ed671f0094dcd491235fe503364a261379c84e2225a3c3230a06bce1d3a02316fa8a040b0ffede56c617746dc3b5550549ae3fb07095bb20d",
"@esbuild/android-arm@npm:0.21.5": "9fa871018a9f2198f40fde2c672fcb1b9d3ab5ee602644ea4cf68c548ee2c0b6c60ad851ce85219f84886fd29757d8c49bac28ea48a2a16708a088e32dfe673a",
"@esbuild/android-x64@npm:0.21.5": "24e477ccdaf1437cabe8710bc052a13b975a53617094a225e39823a1c562a71ef975d860ab895c129a813302495d85387143e27068e62fc897a2ac0335e4a2f6",
"@esbuild/darwin-arm64@npm:0.21.5": "67b0e4ebc870d0babb6721328f02b0e75eca5ee8f176220fa194ac5897ce76a27aa4f6d724389a74e1517670f70e766fe03c30875fdebeee5b1f7b22e99c5a1f",
"@esbuild/darwin-x64@npm:0.21.5": "a4b6df47edf4b1e91eeca9d7af18f538e25615e00763709a4cc24a8918e7ac93b9bfc2ef9f44086f16257d05ad99e23c1213a7a1397475d1a78f0a1e773af89a",
"@esbuild/freebsd-arm64@npm:0.21.5": "a4cf357807f2ea445b5191b8e5488070b567e2b534dba24ce6f8f1a332598ee0b9ffa41b3b0e55cd0cf57e2b56f0f1d84413faba182b81cb43bf19edf58a7654",
"@esbuild/freebsd-x64@npm:0.21.5": "8957c1345196e5dabd7d9f290b5292161f5d9955f269051fa7873118cfb5a20c31d70771ea3560b513f879d0948ba32fba915fb1b387571c4fbbb1fbeaf2dd87",
"@esbuild/linux-arm64@npm:0.21.5": "1b95b17ed94eb977e38ea9130e677551b7cf0ccccdb3f23a9f8b59b5d67400817c2a417e4f043295bd3f67796853da2a1b1a8ca201ffe745efb40a144dfdc99c",
"@esbuild/linux-arm@npm:0.21.5": "6bfcd098ada5e6117d028777e5cc58456c2f570157fa0a0dce30c9d05b8389b86f74bf6b862534bf6994d342946c98b6774e1820880fd289765864b668e94c17",
"@esbuild/linux-ia32@npm:0.21.5": "73c249c9918f0c9a9268ffe14fe745f5e7564b309dcea213da08a5e4367ffdfc8df4b004c70f80269dce0f653a3280cfdd8bf9a7a616b5b60649e4faea6e69b5",
"@esbuild/linux-loong64@npm:0.21.5": "60977efe24b3b6e1461d49da07dd57c1234992b9d2e6ac7d0dedfee538321d42be25e496ffb193121d3a6c6ca6ea6722b880e95695824dcc6643a3d9426b2296",
"@esbuild/linux-mips64el@npm:0.21.5": "20fb6c8f6e58f66cd4351034858b2ad85bda4144576b180979305cfabed43780a71934e9f176e476c719f14e37253b231a43d46638ad232989d5f4dd72ec6b75",
"@esbuild/linux-ppc64@npm:0.21.5": "69f2ef1d127f48bc14cec479ae1a96dbf5fea651e0a3f148486f73495d2acb91acdaa164cd80648844916f05e7f9f9665a1864dd394e7f9acf96bea70937e6b5",
"@esbuild/linux-riscv64@npm:0.21.5": "60c749d87c0f67cc67c5cc0d82aa597b7a807bc52510a16960337433bdbc8fa9f3c46eba98080106c0971e404e2250ca11c441bb4ae5b7a7d78b4095e3a70363",
"@esbuild/linux-s390x@npm:0.21.5": "a14ff0484b962b374fd1e4662a53f8dd8999ba39fcf891f15631dfb2802c8d18893d6e366c42d28d55885e5804b7d6252c0e3cee038c241285c9b537ef12b4ae",
"@esbuild/linux-x64@npm:0.21.5": "9e5663fcace9c8456e9934a9ed6e7428db4080024eef3bfeaf82d476120bd881382c958be2785463d6b44467b3d3f870d6cce09a9cb37bcef19afeb97814d674",
"@esbuild/netbsd-x64@npm:0.21.5": "3cb6115c4557d653c7ad6d2be5b4ed7a688b14d85b7b7108a1a57dda0b2cca3f8ed13560fa6639da8788f860b75eb714a17cfb7ba8f967e93bdf40c9b3a1cde1",
"@esbuild/openbsd-x64@npm:0.21.5": "1caf0b502d6e2612ffd3e62589de2b9cd48cd742818746011d437e2d5787df4984f7c17b7a536aa20f12d04e519c859d755a7b57e6db0ed277054bd9c1036e85",
"@esbuild/sunos-x64@npm:0.21.5": "676da7301c7c600bb7de2523ecf5d877128da3c125fd8136533f5be38ca15d9f800b2fbbd396ca37d44c5daa51b8124d8a4728bb18245cd2becb3191b897c45a",
"@esbuild/win32-arm64@npm:0.21.5": "9b2ab87429efd3c2697dc5c7948ea57b57757b6e4709469e773b73cd5fe4b7fda5912073f4c3bdf9d0346b8f3ae443367a63bcd51de24fb81b9f592712eb3366",
"@esbuild/win32-ia32@npm:0.21.5": "c1fe3276507d82202c464cd4809e67e6f151e29ed9de05c32d086dfe30207db15e646911ebc7f50df659891bfee292a25062792c589c2ff769be238c6b5fb8be",
"@esbuild/win32-x64@npm:0.21.5": "5d7b28baa9c22684d35ec0515f6d36f8f583f26733c8e84c7f78edf17b8a7d133819267486f2fd66f20ca3a810896f11c3c81106d745040c2f07ade314846bf1",
"@rollup/rollup-android-arm-eabi@npm:4.25.0": "f2d7423f54f078bd5529d9c46fb8e6935e20cf33340a94375817af97251762dee8ee2a0b88f0f93d6154e43500ec45f6a8728c577fe7ed5bd0efcc7d38a02117",
"@rollup/rollup-android-arm64@npm:4.25.0": "c7f10f9cef68029447f509221ed44c75624296316449d5a40afc1c707653d23447be7092111b2bbb36d9fe918d05c7b144542e0f41d35254a7228fd711f5df0b",
"@rollup/rollup-darwin-arm64@npm:4.25.0": "86b23c2afe01bd4be8f20c7d4c500abdc03b4e1921433c5c8b4aed26a21c6288e77a6bf24cf367ce32598354830c29c561ff537e74ee86129d77b454ad03764a",
"@rollup/rollup-darwin-x64@npm:4.25.0": "36badafbeb30865194bb45ce8aba405bd0551f7134a9bec0661d19ccc0f60d6e28fb688c1bb42edf4ecd779a97125970ddc7ed92cb9d69edc80f42c671592209",
"@rollup/rollup-freebsd-arm64@npm:4.25.0": "b91c9de03945591de71b4d989bd1437f9e4f9a3e719bc9ee8cee8b8e62e1be2dbf9c140abc87ccfb1436ed1e3f545ee352ad56563f47f7b101232ad92cca0a26",
"@rollup/rollup-freebsd-x64@npm:4.25.0": "7b375aa4e7aa333802ab3438a3b92856b9e0653e05f8a0194fdbd59179c1e435bd7dfcc3c4241224856dabe66d866d6ce0a543ffd68c7fefb885c78a560c2b94",
"@rollup/rollup-linux-arm-gnueabihf@npm:4.25.0": "7a8d3c4932c84f8111466ca749fc1250c5948edcde4e3149bc1ae2d9f9b32a03d976ad2dec8ffd392241623ee4913df3e4e1f76c185e4a3ead90f5f3cb24a000",
"@rollup/rollup-linux-arm-musleabihf@npm:4.25.0": "7367c95d900c351e12ce95e56f12b4d758e781eda9236d792c3e0af75c8967951cf0eb97db3467b63892d852cddfcb6d9632447a5038f1956bdf372ea97827ee",
"@rollup/rollup-linux-arm64-gnu@npm:4.25.0": "6b5c1edc8cb456634c2cc410f581e1afaa1715a35b83f01684ea344b278b0ab7d1ed3285accf295433494cf814cbb8dd887273c78769f6ad68a5cfd8e42a76c8",
"@rollup/rollup-linux-arm64-musl@npm:4.25.0": "79966c734c4efb3fcd01187c642ef85b9ace5bdb42659862520c7871fa1ce6e00e5ca0b9a900775b17d2a7629d8ecc50d3d5533f539b80e9717bfdc8303ba431",
"@rollup/rollup-linux-powerpc64le-gnu@npm:4.25.0": "4682aa839f9d5fa3b03892090cb686df6ca99aa1f18a88e48a19356a0bb7a3c69241d9aa54cefbbee9064dff82aae17d50106b1dfae4bd5af8006ea021bff7ef",
"@rollup/rollup-linux-riscv64-gnu@npm:4.25.0": "67314611e708d2904a0569611fcf01781a9a05f70d0702554d81906b80af1f92acfb012874108779fabb57c866714d1d79be9ff70f0b7820bde4ee2c0c9c97b4",
"@rollup/rollup-linux-s390x-gnu@npm:4.25.0": "823d5aa92b335fc7f291f5ac6d3e5ecb1e58fcac3ed1e2e5c1f50fa73afe710532c9002f72be2cd04b47c583a4c42d075bfb83ff37930245f9b865ff4e13f73f",
"@rollup/rollup-linux-x64-gnu@npm:4.25.0": "76604cf59202d091cbff6aea172bd0705cb8b49a21b7ca946bd31806f543c903f9381f6a2394029c228f395a9b1eb1c27eaf8b00b7943539e88a46cf2fd7560f",
"@rollup/rollup-linux-x64-musl@npm:4.25.0": "e90bf30b1ad823d5a01ebbca7343206cbb9a216f6b13eb517675fe70c18e009097329fd8507b9aeaab7307a124355259bcdc84ffb3c6d81fdb90d9b0d917d82d",
"@rollup/rollup-win32-arm64-msvc@npm:4.25.0": "0426d6fb38a910b9613085db4e57449be956a22c58c173a8d8fcb88b8a1e15d86064c4e678aa3d4750dbfcfe8b0b17af58af1824a4e6114b916c0c8a2399fd88",
"@rollup/rollup-win32-ia32-msvc@npm:4.25.0": "1fe8af4f364e349855b65a91b224284312b609ee801a67e37c74a17099018d4a82bd849d9ffedd9c02dd7a7647a51507bb0085ce2ed21e1f8372912414fdb1e1",
"@rollup/rollup-win32-x64-msvc@npm:4.25.0": "d8905143cbf990cfef4606d6cb7fa5e39d71b543898bb192057bb517245755d54aa6e38dd350ac11fcff62014c4ad027e9131fa066793754d70d2271ff2709af",
"electron-installer-debian@npm:3.2.0": "9ffb1fe15cf291ab23cd6ef51e20b30ebe003c58f745bc5373a3c0800f793f0cfccebfc01eec1cd6658672522a7dcb9733441cdcf9657624606333a5738538a1",
"electron-installer-redhat@npm:3.4.0": "78d9d76e04624e8140fdd8fc8ab9c807eac1ca49650ca1efed6ef8ff4577043413f8f4da614896cd7e6b3f93d4ed73ebca43a34d54fea96ba6dd36f2a979859a"
}
174 changes: 109 additions & 65 deletions pkgs/by-name/yt/ytmdesktop/package.nix
Original file line number Diff line number Diff line change
@@ -1,92 +1,142 @@
{
lib,
asar,
commandLineArgs ? "",
copyDesktopItems,
electron_33,
fetchurl,
stdenv,

fetchFromGitHub,
makeDesktopItem,

copyDesktopItems,
makeWrapper,
stdenv,
zstd,
nodejs,
yarn-berry_4,
zip,

electron,
commandLineArgs ? "",
}:

let
yarn-berry = yarn-berry_4;
in
stdenv.mkDerivation (finalAttrs: {
pname = "ytmdesktop";
version = "2.0.8";

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";
})
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 = [
# instead of runnning git during the build process
# use the .COMMIT file generated in the fetcher FOD
./git-rev-parse.patch
];

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=";
};

nativeBuildInputs = [
asar
copyDesktopItems
makeWrapper
zstd
nodejs
yarn-berry
yarn-berry.yarnBerryConfigHook
zip
];

src = fetchurl {
url = "https://github.com/ytmdesktop/ytmdesktop/releases/download/v${finalAttrs.version}/youtube-music-desktop-app_${finalAttrs.version}_amd64.deb";
hash = "sha256-CwidVf4i9CeD/a8u5sZrBpoYzlZqi9ptFxljr9VmKq8=";
};
# Don't auto-run scripts of dependencies
# We don't need any native modules, so this is fine
env.YARN_ENABLE_SCRIPTS = "0";

unpackPhase = ''
runHook preUnpack
buildPhase = ''
runHook preBuild

ar x $src data.tar.zst
tar xf data.tar.zst
cp -r ${electron.dist} electron-dist
chmod -R u+w electron-dist

runHook preUnpack
'';

postPatch = ''
pushd usr/lib/youtube-music-desktop-app
pushd electron-dist
zip -0Xqr ../electron.zip .
popd

asar extract resources/app.asar patched-asar
rm -r electron-dist

# workaround for https://github.com/electron/electron/issues/31121
substituteInPlace patched-asar/.vite/main/index.js \
--replace-fail "process.resourcesPath" "'$out/lib/resources'"
# 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"'

asar pack patched-asar resources/app.asar
yarn run package

popd
runHook postBuild
'';

installPhase = ''
runHook preInstall
installPhase =
''
runHook preInstall
''
+ lib.optionalString stdenv.hostPlatform.isLinux ''

mkdir -p $out/{lib,share/pixmaps}
mkdir -p "$out"/share/ytmdesktop
cp -r out/*/{locales,resources{,.pak}} "$out"/share/ytmdesktop

cp -r usr/lib/youtube-music-desktop-app/{locales,resources{,.pak}} $out/lib
cp usr/share/pixmaps/youtube-music-desktop-app.png $out/share/pixmaps/ytmdesktop.png
install -Dm644 src/assets/icons/ytmd.png "$out"/share/pixmaps/ytmdesktop.png

runHook postInstall
'';
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

fixupPhase = ''
runHook preFixup
wrapProgram "$out"/Applications/"YouTube Music Desktop App".app/Contents/MacOS/youtube-music-desktop-app \
--add-flags ${lib.escapeShellArg commandLineArgs}

makeWrapper ${lib.getExe electron_33} $out/bin/ytmdesktop \
--add-flags $out/lib/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}
makeWrapper "$out"/Applications/"YouTube Music Desktop App".app/Contents/MacOS/youtube-music-desktop-app "$out"/bin/ytmdesktop
''
+ ''
runHook postInstall
'';

runHook preFixup
'';
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";
})
];

meta = {
changelog = "https://github.com/ytmdesktop/ytmdesktop/tag/v${finalAttrs.version}";
Expand All @@ -96,12 +146,6 @@ stdenv.mkDerivation (finalAttrs: {
license = lib.licenses.gpl3Only;
mainProgram = "ytmdesktop";
maintainers = [ lib.maintainers.cjshearer ];
inherit (electron_33.meta) platforms;
# While the files we extract from the .deb are cross-platform (javascript), the installation
# process for darwin is different, and I don't have a test device. PRs are welcome if you can
# add the correct installation steps. I would suggest looking at the following:
# https://www.electronjs.org/docs/latest/tutorial/application-distribution#manual-packaging
# https://github.com/NixOS/nixpkgs/blob/master/pkgs/applications/networking/instant-messengers/jitsi-meet-electron/default.nix
badPlatforms = lib.platforms.darwin;
inherit (electron.meta) platforms;
};
})