at 24.11-pre 79 lines 2.4 kB view raw
1{ lib 2, stdenv 3, fetchurl 4, fetchFromGitHub 5, makeWrapper 6, meson 7, ninja 8, pkg-config 9, runtimeShell 10, installShellFiles 11 12, android-tools 13, ffmpeg 14, libusb1 15, SDL2 16}: 17 18let 19 version = "2.4"; 20 prebuilt_server = fetchurl { 21 name = "scrcpy-server"; 22 inherit version; 23 url = "https://github.com/Genymobile/scrcpy/releases/download/v${version}/scrcpy-server-v${version}"; 24 hash = "sha256-k8Jyt0OGBcBV4Sf3REBk7Xj6nKSfgRVnd/0gHnnOe6M="; 25 }; 26in 27stdenv.mkDerivation rec { 28 pname = "scrcpy"; 29 inherit version; 30 31 src = fetchFromGitHub { 32 owner = "Genymobile"; 33 repo = "scrcpy"; 34 rev = "refs/tags/v${version}"; 35 hash = "sha256-x1feZgCR3ZUi40/YZSjDULYk4W9Pjo17cn8RqcOoeoE="; 36 }; 37 38 # display.c: When run without a hardware accelerator, this allows the command to continue working rather than failing unexpectedly. 39 # This can happen when running on non-NixOS because then scrcpy seems to have a hard time using the host OpenGL-supporting hardware. 40 # It would be better to fix the OpenGL problem, but that seems much more intrusive. 41 postPatch = '' 42 substituteInPlace app/src/display.c \ 43 --replace "SDL_RENDERER_ACCELERATED" "SDL_RENDERER_ACCELERATED || SDL_RENDERER_SOFTWARE" 44 ''; 45 46 nativeBuildInputs = [ makeWrapper meson ninja pkg-config installShellFiles ]; 47 48 buildInputs = [ ffmpeg SDL2 libusb1 ]; 49 50 # Manually install the server jar to prevent Meson from "fixing" it 51 preConfigure = '' 52 echo -n > server/meson.build 53 ''; 54 55 postInstall = '' 56 mkdir -p "$out/share/scrcpy" 57 ln -s "${prebuilt_server}" "$out/share/scrcpy/scrcpy-server" 58 59 # runtime dep on `adb` to push the server 60 wrapProgram "$out/bin/scrcpy" --prefix PATH : "${android-tools}/bin" 61 '' + lib.optionalString stdenv.isLinux '' 62 substituteInPlace $out/share/applications/scrcpy-console.desktop \ 63 --replace "/bin/bash" "${runtimeShell}" 64 ''; 65 66 meta = with lib; { 67 description = "Display and control Android devices over USB or TCP/IP"; 68 homepage = "https://github.com/Genymobile/scrcpy"; 69 changelog = "https://github.com/Genymobile/scrcpy/releases/tag/v${version}"; 70 sourceProvenance = with sourceTypes; [ 71 fromSource 72 binaryBytecode # server 73 ]; 74 license = licenses.asl20; 75 platforms = platforms.unix; 76 maintainers = with maintainers; [ deltaevo ]; 77 mainProgram = "scrcpy"; 78 }; 79}