evcc: 0.131.4 -> 0.131.5
[NixPkgs.git] / pkgs / by-name / yt / ytmdesktop / package.nix
blobf6e04c930b7b2b168cf6ce2b3ac0ae2da2698fbf
2   lib,
3   asar,
4   commandLineArgs ? "",
5   copyDesktopItems,
6   electron_33,
7   fetchurl,
8   makeDesktopItem,
9   makeWrapper,
10   stdenv,
11   zstd,
13 stdenv.mkDerivation (finalAttrs: {
14   pname = "ytmdesktop";
15   version = "2.0.6";
17   desktopItems = [
18     (makeDesktopItem {
19       desktopName = "YouTube Music Desktop App";
20       exec = "ytmdesktop";
21       icon = "ytmdesktop";
22       name = "ytmdesktop";
23       genericName = finalAttrs.meta.description;
24       mimeTypes = [ "x-scheme-handler/ytmd" ];
25       categories = [
26         "AudioVideo"
27         "Audio"
28       ];
29       startupNotify = true;
30       startupWMClass = "YouTube Music Desktop App";
31     })
32   ];
34   nativeBuildInputs = [
35     asar
36     copyDesktopItems
37     makeWrapper
38     zstd
39   ];
41   src = fetchurl {
42     url = "https://github.com/ytmdesktop/ytmdesktop/releases/download/v${finalAttrs.version}/youtube-music-desktop-app_${finalAttrs.version}_amd64.deb";
43     hash = "sha256-uLTnVA9ooGlbtmUGoYtrT9IlOhTAJpEXMr1GSs3ae/8=";
44   };
46   unpackPhase = ''
47     runHook preUnpack
49     ar x $src data.tar.zst
50     tar xf data.tar.zst
52     runHook preUnpack
53   '';
55   postPatch = ''
56     pushd usr/lib/youtube-music-desktop-app
58     asar extract resources/app.asar patched-asar
60     # workaround for https://github.com/electron/electron/issues/31121
61     substituteInPlace patched-asar/.webpack/main/index.js \
62       --replace-fail "process.resourcesPath" "'$out/lib/resources'"
64     asar pack patched-asar resources/app.asar
66     popd
67   '';
69   installPhase = ''
70     runHook preInstall
72     mkdir -p $out/{lib,share/pixmaps}
74     cp -r usr/lib/youtube-music-desktop-app/{locales,resources{,.pak}} $out/lib
75     cp usr/share/pixmaps/youtube-music-desktop-app.png $out/share/pixmaps/ytmdesktop.png
77     runHook postInstall
78   '';
80   fixupPhase = ''
81     runHook preFixup
83     makeWrapper ${lib.getExe electron_33} $out/bin/ytmdesktop \
84       --add-flags $out/lib/resources/app.asar \
85       --add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--ozone-platform-hint=auto --enable-features=WaylandWindowDecorations}}" \
86       --add-flags ${lib.escapeShellArg commandLineArgs}
88     runHook preFixup
89   '';
91   meta = {
92     changelog = "https://github.com/ytmdesktop/ytmdesktop/tag/v${finalAttrs.version}";
93     description = "A Desktop App for YouTube Music";
94     downloadPage = "https://github.com/ytmdesktop/ytmdesktop/releases";
95     homepage = "https://ytmdesktop.app/";
96     license = lib.licenses.gpl3Only;
97     mainProgram = finalAttrs.pname;
98     maintainers = [ lib.maintainers.cjshearer ];
99     inherit (electron_33.meta) platforms;
100     # While the files we extract from the .deb are cross-platform (javascript), the installation
101     # process for darwin is different, and I don't have a test device. PRs are welcome if you can
102     # add the correct installation steps. I would suggest looking at the following:
103     # https://www.electronjs.org/docs/latest/tutorial/application-distribution#manual-packaging
104     # https://github.com/NixOS/nixpkgs/blob/master/pkgs/applications/networking/instant-messengers/jitsi-meet-electron/default.nix
105     badPlatforms = lib.platforms.darwin;
106   };