11{
22 lib ,
3+ buildNpmPackage ,
4+ fetchFromGitHub ,
5+ callPackage ,
6+ libdbusmenu ,
7+ xdg-utils ,
8+ makeShellWrapper ,
9+ copyDesktopItems ,
10+ makeDesktopItem ,
311 stdenv ,
4- fetchurl ,
5- autoPatchelfHook ,
6- dpkg ,
7- makeWrapper ,
812 wrapGAppsHook3 ,
9- alsa-lib ,
13+ glib ,
14+ gtk3 ,
15+ gtk4 ,
1016 at-spi2-atk ,
11- at-spi2-core ,
12- atk ,
17+ libdrm ,
18+ libgbm ,
19+ libxkbcommon ,
20+ libxshmfence ,
21+ libGL ,
22+ vulkan-loader ,
23+ alsa-lib ,
1324 cairo ,
1425 cups ,
1526 dbus ,
1627 expat ,
17- ffmpeg ,
18- fontconfig ,
19- freetype ,
2028 gdk-pixbuf ,
21- glib ,
22- gtk3 ,
23- libappindicator-gtk3 ,
24- libdbusmenu ,
25- libdrm ,
26- libnotify ,
27- libpulseaudio ,
28- libsecret ,
29- libuuid ,
30- libxkbcommon ,
31- libgbm ,
3229 nss ,
30+ nspr ,
31+ libX11 ,
32+ libxcb ,
33+ libXcomposite ,
34+ libXdamage ,
35+ libXext ,
36+ libXfixes ,
37+ libXrandr ,
38+ libxkbfile ,
3339 pango ,
3440 systemd ,
35- xdg-utils ,
36- xorg ,
37- libGL ,
38- } :
39-
40- stdenv . mkDerivation ( finalAttrs : {
41- pname = "tidal-hifi" ;
42- version = "5.18.2" ;
41+ pciutils ,
42+ libnotify ,
43+ pipewire ,
44+ libsecret ,
45+ libpulseaudio ,
46+ speechd-minimal ,
4347
44- src = fetchurl {
45- url = "https://github.com/Mastermindzh/tidal-hifi/releases/download/${ finalAttrs . version } /tidal-hifi_${ finalAttrs . version } _amd64.deb" ;
46- sha256 = "sha256-jo3vnq7ul7e+UsaBswil8EctUxVJMcTxo77YyQ2ncIM=" ;
47- } ;
48+ castlabs-electron ? callPackage ./electron.nix { } ,
49+ } :
4850
49- nativeBuildInputs = [
50- autoPatchelfHook
51- dpkg
52- makeWrapper
53- wrapGAppsHook3
54- ] ;
51+ let
52+ version = "5.19.0" ;
5553
56- buildInputs = [
54+ electronLibPath = lib . makeLibraryPath [
5755 alsa-lib
5856 at-spi2-atk
59- at-spi2-core
60- atk
6157 cairo
6258 cups
6359 dbus
6460 expat
65- ffmpeg
66- fontconfig
67- freetype
6861 gdk-pixbuf
6962 glib
7063 gtk3
64+ gtk4
65+ nss
66+ nspr
67+ libX11
68+ libxcb
69+ libXcomposite
70+ libXdamage
71+ libXext
72+ libXfixes
73+ libXrandr
74+ libxkbfile
7175 pango
76+ pciutils
77+ stdenv . cc . cc
7278 systemd
73- libgbm
74- nss
75- libuuid
76- libdrm
7779 libnotify
80+ pipewire
7881 libsecret
7982 libpulseaudio
83+ speechd-minimal
84+ libdrm
85+ libgbm
8086 libxkbcommon
81- libappindicator-gtk3
82- xorg . libX11
83- xorg . libxcb
84- xorg . libXcomposite
85- xorg . libXcursor
86- xorg . libXdamage
87- xorg . libXext
88- xorg . libXfixes
89- xorg . libXi
90- xorg . libXrandr
91- xorg . libXrender
92- xorg . libXScrnSaver
93- xorg . libxshmfence
94- xorg . libXtst
87+ libxshmfence
9588 libGL
89+ vulkan-loader
90+ ] ;
91+ in
92+ buildNpmPackage {
93+ pname = "tidal-hifi" ;
94+ inherit version ;
95+
96+ src = fetchFromGitHub {
97+ owner = "Mastermindzh" ;
98+ repo = "tidal-hifi" ;
99+ tag = version ;
100+ hash = "sha256-/pPmfgKwrtOrEu7YVJTuQF/FIMa+W6uSnFbMFuyURFQ=" ;
101+ } ;
102+
103+ nativeBuildInputs = [
104+ makeShellWrapper
105+ wrapGAppsHook3
106+ copyDesktopItems
96107 ] ;
97108
98109 runtimeDependencies = [
@@ -102,36 +113,101 @@ stdenv.mkDerivation (finalAttrs: {
102113 xdg-utils
103114 ] ;
104115
116+ npmDepsHash = "sha256-TNhD/ZkqJtsidAEIOL/WmJZw09BuFgd4ECnzbieNhVY=" ;
117+ forceGitDeps = true ;
118+ makeCacheWritable = true ;
119+
120+ env . ELECTRON_SKIP_BINARY_DOWNLOAD = "1" ;
121+
122+ buildPhase = ''
123+ runHook preBuild
124+
125+ npm run compile
126+ npm exec electron-builder -- \
127+ --dir \
128+ --config build/electron-builder.base.yml \
129+ -c.electronDist=${ castlabs-electron . dist } \
130+ -c.electronVersion=${ castlabs-electron . version }
131+
132+ runHook postBuild
133+ '' ;
134+
135+ desktopItems = [
136+ ( makeDesktopItem {
137+ name = "TIDAL Hi-Fi" ;
138+ desktopName = "tidal-hifi" ;
139+ genericName = "TIDAL Hi-Fi" ;
140+ comment = "The web version of listen.tidal.com running in electron with hifi support thanks to widevine." ;
141+ icon = "tidal-hifi" ;
142+ startupNotify = true ;
143+ terminal = false ;
144+ type = "Application" ;
145+ categories = [
146+ "Network"
147+ "Application"
148+ "AudioVideo"
149+ "Audio"
150+ "Video"
151+ ] ;
152+ startupWMClass = "tidal-hifi" ;
153+ mimeTypes = [ "x-scheme-handler/tidal" ] ;
154+ extraConfig . X-PulseAudio-Properties = "media.role=music" ;
155+ } )
156+ ] ;
157+
158+ dontWrapGApps = true ;
159+
105160 installPhase = ''
106161 runHook preInstall
107162
108- mkdir -p "$out/bin"
109- cp -R "opt" "$out"
110- cp -R "usr/share" "$out/share"
111- chmod -R g-w "$out"
163+ for i in 16 22 24 32 48 64 128 256 384; do
164+ install -Dm644 "assets/icons/$i"x"$i.png" "$out/share/icons/hicolor/$i"x"$i/apps/tidal-hifi.png"
165+ done
166+
167+ mv dist/linux-unpacked "$out/share/tidal-hifi"
112168
113169 runHook postInstall
114170 '' ;
115171
172+ # see: pkgs/development/tools/electron/binary/generic.nix
116173 postFixup = ''
117- makeWrapper $out/opt/tidal-hifi/tidal-hifi $out/bin/tidal-hifi \
118- --prefix LD_LIBRARY_PATH : "${ lib . makeLibraryPath finalAttrs . buildInputs } " \
119- --add-flags "\'' ${NIXOS_OZONE_WL:+\'' ${WAYLAND_DISPLAY:+--ozone-platform-hint=auto --enable-features=WaylandWindowDecorations --enable-wayland-ime=true}}" \
174+ patchelf \
175+ --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
176+ --set-rpath "${ electronLibPath } :$out/share/tidal-hifi" \
177+ $out/share/tidal-hifi/tidal-hifi \
178+ $out/share/tidal-hifi/chrome_crashpad_handler
179+
180+ # patch libANGLE
181+ patchelf \
182+ --set-rpath "${
183+ lib . makeLibraryPath [
184+ libGL
185+ pciutils
186+ vulkan-loader
187+ ]
188+ } " \
189+ $out/share/tidal-hifi/lib*GL*
190+
191+ # replace bundled vulkan-loader
192+ rm "$out/share/tidal-hifi/libvulkan.so.1"
193+ ln -s -t "$out/share/tidal-hifi" "${ lib . getLib vulkan-loader } /lib/libvulkan.so.1"
194+
195+ makeShellWrapper "$out/share/tidal-hifi/tidal-hifi" "$out/bin/tidal-hifi" \
196+ --add-flags "\'' ${NIXOS_OZONE_WL:+\'' ${WAYLAND_DISPLAY:+--ozone-platform-hint=auto --enable-features=WaylandWindowDecorations}}" \
120197 "'' ${gappsWrapperArgs[@]}"
121- substituteInPlace $out/share/applications/tidal-hifi.desktop \
122- --replace "/opt/tidal-hifi/tidal-hifi" "tidal-hifi"
123198 '' ;
124199
125200 meta = {
126- changelog = "https://github.com/Mastermindzh/tidal-hifi/releases/tag/${ finalAttrs . version } " ;
201+ changelog = "https://github.com/Mastermindzh/tidal-hifi/releases/tag/${ version } " ;
127202 description = "Web version of Tidal running in electron with hifi support thanks to widevine" ;
128203 homepage = "https://github.com/Mastermindzh/tidal-hifi" ;
129204 license = lib . licenses . mit ;
130205 maintainers = with lib . maintainers ; [
206+ gerg-l
131207 qbit
132208 spikespaz
133209 ] ;
134210 platforms = lib . platforms . linux ;
135211 mainProgram = "tidal-hifi" ;
136212 } ;
137- } )
213+ }
0 commit comments