biglybt: 3.5.0.0 -> 3.6.0.0
[NixPkgs.git] / pkgs / applications / networking / mkchromecast / default.nix
blobf6364f5ba57262f39b6afbe170204451e3cf1f9d
1 { lib, stdenv
2 , fetchFromGitHub
3 , python3Packages
4 , sox
5 , flac
6 , lame
7 , wrapQtAppsHook
8 , ffmpeg
9 , vorbis-tools
10 , pulseaudio
11 , nodejs
12 , youtube-dl
13 , opusTools
14 , gst_all_1
15 , enableSonos ? true
16 , qtwayland
18 let packages = [
19   vorbis-tools
20   sox
21   flac
22   lame
23   opusTools
24   gst_all_1.gstreamer
25   nodejs
26   ffmpeg
27   youtube-dl
28 ] ++ lib.optionals stdenv.isLinux [ pulseaudio ];
31 python3Packages.buildPythonApplication {
32   pname = "mkchromecast-unstable";
33   version = "2022-10-31";
35   src = fetchFromGitHub {
36     owner = "muammar";
37     repo = "mkchromecast";
38     rev = "0de9fd78c4122dec4f184aeae2564790b45fe6dc";
39     sha256 = "sha256-dxsIcBPrZaXlsfzOEXhYj2qoK5LRducJG2ggMrMMl9Y=";
40   };
42   buildInputs = lib.optional stdenv.isLinux qtwayland;
43   propagatedBuildInputs = with python3Packages; ([
44     pychromecast
45     psutil
46     mutagen
47     flask
48     netifaces
49     requests
50     pyqt5
51   ] ++ lib.optionals enableSonos [ soco ]);
53   postPatch = ''
54     substituteInPlace setup.py \
55       --replace 'platform.system() == "Darwin"' 'False' \
56       --replace 'platform.system() == "Linux"' 'True'
57   '';
59   nativeBuildInputs = [ wrapQtAppsHook ];
61   # Relies on an old version (0.7.7) of PyChromecast unavailable in Nixpkgs.
62   # Is also I/O bound and impure, testing an actual device, so we disable.
63   doCheck = false;
65   dontWrapQtApps = true;
67   makeWrapperArgs = [
68     "\${qtWrapperArgs[@]}"
69     "--prefix PATH : ${lib.makeBinPath packages}"
70   ];
72   postInstall = ''
73     substituteInPlace $out/${python3Packages.python.sitePackages}/mkchromecast/video.py \
74       --replace '/usr/share/mkchromecast/nodejs/' '${placeholder "out"}/share/mkchromecast/nodejs/'
75   '' + lib.optionalString stdenv.isDarwin ''
76     install -Dm 755 -t $out/bin bin/audiodevice
77     substituteInPlace $out/${python3Packages.python.sitePackages}/mkchromecast/audio_devices.py \
78       --replace './bin/audiodevice' '${placeholder "out"}/bin/audiodevice'
79   '';
81   meta = with lib; {
82     homepage = "https://mkchromecast.com/";
83     description = "Cast macOS and Linux Audio/Video to your Google Cast and Sonos Devices";
84     license = licenses.mit;
85     maintainers = with maintainers; [ shou ];
86     mainProgram = "mkchromecast";
87   };