1 { lib, stdenv, fetchurl, fetchFromGitHub, makeWrapper
15 prebuilt_server = fetchurl {
16 url = "https://github.com/Genymobile/scrcpy/releases/download/v${version}/scrcpy-server-v${version}";
17 sha256 = "sha256-rnSoHqecDcclDlhmJ8J4wKmoxd5GyftcOMFn+xo28FY=";
20 stdenv.mkDerivation rec {
24 src = fetchFromGitHub {
28 sha256 = "sha256-mL0lSZUPMMcLGq4iPp/IgYZLaTeey9Nv9vVwY1gaIRk=";
32 # screen.c: When run without a hardware accelerator, this allows the command to continue working rather than failing unexpectedly.
33 # This can happen when running on non-NixOS because then scrcpy seems to have a hard time using the host OpenGL-supporting hardware.
34 # It would be better to fix the OpenGL problem, but that seems much more intrusive.
36 substituteInPlace app/src/screen.c \
37 --replace "SDL_RENDERER_ACCELERATED" "SDL_RENDERER_ACCELERATED || SDL_RENDERER_SOFTWARE"
40 nativeBuildInputs = [ makeWrapper meson ninja pkg-config installShellFiles ];
42 buildInputs = [ ffmpeg SDL2 libusb1 ];
44 # Manually install the server jar to prevent Meson from "fixing" it
46 echo -n > server/meson.build
50 mkdir -p "$out/share/scrcpy"
51 ln -s "${prebuilt_server}" "$out/share/scrcpy/scrcpy-server"
53 # runtime dep on `adb` to push the server
54 wrapProgram "$out/bin/scrcpy" --prefix PATH : "${platform-tools}/bin"
58 description = "Display and control Android devices over USB or TCP/IP";
59 homepage = "https://github.com/Genymobile/scrcpy";
60 sourceProvenance = with sourceTypes; [
62 binaryBytecode # server
64 license = licenses.asl20;
65 platforms = platforms.unix;
66 maintainers = with maintainers; [ deltaevo lukeadams msfjarvis ];