Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at devShellTools-shell 122 lines 3.3 kB view raw
1{ 2 lib, 3 fetchFromGitHub, 4 makeWrapper, 5 electron, 6 python3, 7 stdenv, 8 copyDesktopItems, 9 nodejs, 10 pnpm, 11 makeDesktopItem, 12}: 13 14stdenv.mkDerivation (finalAttrs: { 15 pname = "youtube-music"; 16 version = "3.9.0"; 17 18 src = fetchFromGitHub { 19 owner = "th-ch"; 20 repo = "youtube-music"; 21 rev = "v${finalAttrs.version}"; 22 hash = "sha256-xaHYNfW5ZLYiaeJ0F32NQ87woMh6K4Ea9rjgNOyabck="; 23 }; 24 25 pnpmDeps = pnpm.fetchDeps { 26 inherit (finalAttrs) pname version src; 27 fetcherVersion = 1; 28 hash = "sha256-xIQyTetHU37gTxCcQp4VCqzGdIfVQGy/aORCVba6YQ0="; 29 }; 30 31 nativeBuildInputs = [ 32 makeWrapper 33 python3 34 nodejs 35 pnpm.configHook 36 ] 37 ++ lib.optionals (!stdenv.hostPlatform.isDarwin) [ copyDesktopItems ]; 38 39 ELECTRON_SKIP_BINARY_DOWNLOAD = 1; 40 41 postBuild = 42 lib.optionalString stdenv.hostPlatform.isDarwin '' 43 cp -R ${electron.dist}/Electron.app Electron.app 44 chmod -R u+w Electron.app 45 '' 46 + '' 47 pnpm build 48 ./node_modules/.bin/electron-builder \ 49 --dir \ 50 -c.electronDist=${if stdenv.hostPlatform.isDarwin then "." else electron.dist} \ 51 -c.electronVersion=${electron.version} 52 ''; 53 54 installPhase = '' 55 runHook preInstall 56 57 '' 58 + lib.optionalString stdenv.hostPlatform.isDarwin '' 59 mkdir -p $out/{Applications,bin} 60 mv pack/mac*/YouTube\ Music.app $out/Applications 61 makeWrapper $out/Applications/YouTube\ Music.app/Contents/MacOS/YouTube\ Music $out/bin/youtube-music 62 '' 63 + lib.optionalString (!stdenv.hostPlatform.isDarwin) '' 64 mkdir -p "$out/share/lib/youtube-music" 65 cp -r pack/*-unpacked/{locales,resources{,.pak}} "$out/share/lib/youtube-music" 66 67 pushd assets/generated/icons/png 68 for file in *.png; do 69 install -Dm0644 $file $out/share/icons/hicolor/''${file//.png}/apps/youtube-music.png 70 done 71 popd 72 '' 73 + '' 74 75 runHook postInstall 76 ''; 77 78 postFixup = lib.optionalString (!stdenv.hostPlatform.isDarwin) '' 79 makeWrapper ${electron}/bin/electron $out/bin/youtube-music \ 80 --add-flags $out/share/lib/youtube-music/resources/app.asar \ 81 --add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--ozone-platform-hint=auto --enable-features=WaylandWindowDecorations --enable-wayland-ime=true}}" \ 82 --set-default ELECTRON_FORCE_IS_PACKAGED 1 \ 83 --set-default ELECTRON_IS_DEV 0 \ 84 --inherit-argv0 85 ''; 86 87 patches = [ 88 # MPRIS's DesktopEntry property needs to match the desktop entry basename 89 ./fix-mpris-desktop-entry.patch 90 ]; 91 92 desktopItems = [ 93 (makeDesktopItem { 94 name = "com.github.th_ch.youtube_music"; 95 exec = "youtube-music %u"; 96 icon = "youtube-music"; 97 desktopName = "YouTube Music"; 98 startupWMClass = "com.github.th_ch.youtube_music"; 99 categories = [ "AudioVideo" ]; 100 }) 101 ]; 102 103 meta = with lib; { 104 description = "Electron wrapper around YouTube Music"; 105 homepage = "https://th-ch.github.io/youtube-music/"; 106 changelog = "https://github.com/th-ch/youtube-music/blob/master/changelog.md#${ 107 lib.replaceStrings [ "." ] [ "" ] finalAttrs.src.rev 108 }"; 109 license = licenses.mit; 110 maintainers = with maintainers; [ 111 aacebedo 112 SuperSandro2000 113 ]; 114 mainProgram = "youtube-music"; 115 platforms = [ 116 "x86_64-linux" 117 "aarch64-linux" 118 "x86_64-darwin" 119 "aarch64-darwin" 120 ]; 121 }; 122})