mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-01-30 08:44:31 +00:00
e0464e4788
In preparation for the deprecation of `stdenv.isX`. These shorthands are not conducive to cross-compilation because they hide the platforms. Darwin might get cross-compilation for which the continued usage of `stdenv.isDarwin` will get in the way One example of why this is bad and especially affects compiler packages https://www.github.com/NixOS/nixpkgs/pull/343059 There are too many files to go through manually but a treewide should get users thinking when they see a `hostPlatform.isX` in a place where it doesn't make sense. ``` fd --type f "\.nix" | xargs sd --fixed-strings "stdenv.is" "stdenv.hostPlatform.is" fd --type f "\.nix" | xargs sd --fixed-strings "stdenv'.is" "stdenv'.hostPlatform.is" fd --type f "\.nix" | xargs sd --fixed-strings "clangStdenv.is" "clangStdenv.hostPlatform.is" fd --type f "\.nix" | xargs sd --fixed-strings "gccStdenv.is" "gccStdenv.hostPlatform.is" fd --type f "\.nix" | xargs sd --fixed-strings "stdenvNoCC.is" "stdenvNoCC.hostPlatform.is" fd --type f "\.nix" | xargs sd --fixed-strings "inherit (stdenv) is" "inherit (stdenv.hostPlatform) is" fd --type f "\.nix" | xargs sd --fixed-strings "buildStdenv.is" "buildStdenv.hostPlatform.is" fd --type f "\.nix" | xargs sd --fixed-strings "effectiveStdenv.is" "effectiveStdenv.hostPlatform.is" fd --type f "\.nix" | xargs sd --fixed-strings "originalStdenv.is" "originalStdenv.hostPlatform.is" ```
97 lines
2.9 KiB
Nix
97 lines
2.9 KiB
Nix
{ lib
|
|
, fetchFromGitHub
|
|
, makeWrapper
|
|
, electron
|
|
, python3
|
|
, stdenv
|
|
, copyDesktopItems
|
|
, nodejs
|
|
, pnpm
|
|
, makeDesktopItem
|
|
}:
|
|
|
|
stdenv.mkDerivation (finalAttrs: {
|
|
pname = "youtube-music";
|
|
version = "3.5.1";
|
|
|
|
src = fetchFromGitHub {
|
|
owner = "th-ch";
|
|
repo = "youtube-music";
|
|
rev = "v${finalAttrs.version}";
|
|
hash = "sha256-6aAaIugho8yHohEHp0HVkmzIOfhpkNYts6BOKPp9Wbw=";
|
|
};
|
|
|
|
pnpmDeps = pnpm.fetchDeps {
|
|
inherit (finalAttrs) pname version src;
|
|
hash = "sha256-lxqBmtHkyk4mnM/AJQmpyCmvhW2e96vZBkgtoREjEXY=";
|
|
};
|
|
|
|
nativeBuildInputs = [ makeWrapper python3 nodejs pnpm.configHook ]
|
|
++ lib.optionals (!stdenv.hostPlatform.isDarwin) [ copyDesktopItems ];
|
|
|
|
|
|
ELECTRON_SKIP_BINARY_DOWNLOAD = 1;
|
|
|
|
postBuild = lib.optionalString stdenv.hostPlatform.isDarwin ''
|
|
cp -R ${electron.dist}/Electron.app Electron.app
|
|
chmod -R u+w Electron.app
|
|
'' + ''
|
|
pnpm build
|
|
./node_modules/.bin/electron-builder \
|
|
--dir \
|
|
-c.electronDist=${if stdenv.hostPlatform.isDarwin then "." else electron.dist} \
|
|
-c.electronVersion=${electron.version}
|
|
'';
|
|
|
|
installPhase = ''
|
|
runHook preInstall
|
|
|
|
'' + lib.optionalString stdenv.hostPlatform.isDarwin ''
|
|
mkdir -p $out/{Applications,bin}
|
|
mv pack/mac*/YouTube\ Music.app $out/Applications
|
|
makeWrapper $out/Applications/YouTube\ Music.app/Contents/MacOS/YouTube\ Music $out/bin/youtube-music
|
|
'' + lib.optionalString (!stdenv.hostPlatform.isDarwin) ''
|
|
mkdir -p "$out/share/lib/youtube-music"
|
|
cp -r pack/*-unpacked/{locales,resources{,.pak}} "$out/share/lib/youtube-music"
|
|
|
|
pushd assets/generated/icons/png
|
|
for file in *.png; do
|
|
install -Dm0644 $file $out/share/icons/hicolor/''${file//.png}/apps/youtube-music.png
|
|
done
|
|
popd
|
|
'' + ''
|
|
|
|
runHook postInstall
|
|
'';
|
|
|
|
postFixup = lib.optionalString (!stdenv.hostPlatform.isDarwin) ''
|
|
makeWrapper ${electron}/bin/electron $out/bin/youtube-music \
|
|
--add-flags $out/share/lib/youtube-music/resources/app.asar \
|
|
--add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--ozone-platform-hint=auto --enable-features=WaylandWindowDecorations}}" \
|
|
--set-default ELECTRON_FORCE_IS_PACKAGED 1 \
|
|
--set-default ELECTRON_IS_DEV 0 \
|
|
--inherit-argv0
|
|
'';
|
|
|
|
desktopItems = [
|
|
(makeDesktopItem {
|
|
name = "youtube-music";
|
|
exec = "youtube-music %u";
|
|
icon = "youtube-music";
|
|
desktopName = "Youtube Music";
|
|
startupWMClass = "Youtube Music";
|
|
categories = [ "AudioVideo" ];
|
|
})
|
|
];
|
|
|
|
meta = with lib; {
|
|
description = "Electron wrapper around YouTube Music";
|
|
homepage = "https://th-ch.github.io/youtube-music/";
|
|
changelog = "https://github.com/th-ch/youtube-music/blob/master/changelog.md#${lib.replaceStrings ["."] [""] finalAttrs.src.rev}";
|
|
license = licenses.mit;
|
|
maintainers = with maintainers; [ aacebedo SuperSandro2000 ];
|
|
mainProgram = "youtube-music";
|
|
platforms = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];
|
|
};
|
|
})
|