nixpkgs/pkgs/applications/networking/mkchromecast/default.nix
Artturin e0464e4788 treewide: replace stdenv.is with stdenv.hostPlatform.is
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"
```
2024-09-25 00:04:37 +03:00

89 lines
2.2 KiB
Nix

{ lib, stdenv
, fetchFromGitHub
, python3Packages
, sox
, flac
, lame
, wrapQtAppsHook
, ffmpeg
, vorbis-tools
, pulseaudio
, nodejs
, youtube-dl
, opusTools
, gst_all_1
, enableSonos ? true
, qtwayland
}:
let packages = [
vorbis-tools
sox
flac
lame
opusTools
gst_all_1.gstreamer
nodejs
ffmpeg
youtube-dl
] ++ lib.optionals stdenv.hostPlatform.isLinux [ pulseaudio ];
in
python3Packages.buildPythonApplication {
pname = "mkchromecast-unstable";
version = "2022-10-31";
src = fetchFromGitHub {
owner = "muammar";
repo = "mkchromecast";
rev = "0de9fd78c4122dec4f184aeae2564790b45fe6dc";
sha256 = "sha256-dxsIcBPrZaXlsfzOEXhYj2qoK5LRducJG2ggMrMMl9Y=";
};
buildInputs = lib.optional stdenv.hostPlatform.isLinux qtwayland;
propagatedBuildInputs = with python3Packages; ([
pychromecast
psutil
mutagen
flask
netifaces
requests
pyqt5
] ++ lib.optionals enableSonos [ soco ]);
postPatch = ''
substituteInPlace setup.py \
--replace 'platform.system() == "Darwin"' 'False' \
--replace 'platform.system() == "Linux"' 'True'
'';
nativeBuildInputs = [ wrapQtAppsHook ];
# Relies on an old version (0.7.7) of PyChromecast unavailable in Nixpkgs.
# Is also I/O bound and impure, testing an actual device, so we disable.
doCheck = false;
dontWrapQtApps = true;
makeWrapperArgs = [
"\${qtWrapperArgs[@]}"
"--prefix PATH : ${lib.makeBinPath packages}"
];
postInstall = ''
substituteInPlace $out/${python3Packages.python.sitePackages}/mkchromecast/video.py \
--replace '/usr/share/mkchromecast/nodejs/' '${placeholder "out"}/share/mkchromecast/nodejs/'
'' + lib.optionalString stdenv.hostPlatform.isDarwin ''
install -Dm 755 -t $out/bin bin/audiodevice
substituteInPlace $out/${python3Packages.python.sitePackages}/mkchromecast/audio_devices.py \
--replace './bin/audiodevice' '${placeholder "out"}/bin/audiodevice'
'';
meta = with lib; {
homepage = "https://mkchromecast.com/";
description = "Cast macOS and Linux Audio/Video to your Google Cast and Sonos Devices";
license = licenses.mit;
maintainers = with maintainers; [ shou ];
mainProgram = "mkchromecast";
};
}