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