2021-01-15 22:18:51 +00:00
|
|
|
{ lib, stdenv, fetchurl, fetchFromGitHub, makeWrapper
|
2020-04-24 23:36:52 +00:00
|
|
|
, meson
|
|
|
|
, ninja
|
2020-05-29 06:06:01 +00:00
|
|
|
, pkg-config
|
2022-12-28 21:21:41 +00:00
|
|
|
, runtimeShell
|
2022-03-05 16:20:37 +00:00
|
|
|
, installShellFiles
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
, platform-tools
|
2020-08-20 17:08:02 +00:00
|
|
|
, ffmpeg
|
2021-12-06 16:07:01 +00:00
|
|
|
, libusb1
|
2020-04-24 23:36:52 +00:00
|
|
|
, SDL2
|
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
2022-12-28 21:21:41 +00:00
|
|
|
version = "1.25";
|
2020-04-24 23:36:52 +00:00
|
|
|
prebuilt_server = fetchurl {
|
|
|
|
url = "https://github.com/Genymobile/scrcpy/releases/download/v${version}/scrcpy-server-v${version}";
|
2022-12-28 21:21:41 +00:00
|
|
|
sha256 = "sha256-zgMGx7vQaucvbQb37A7jN3SZWmXeceCoOBPstnrsm9s=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
in
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "scrcpy";
|
|
|
|
inherit version;
|
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "Genymobile";
|
|
|
|
repo = pname;
|
|
|
|
rev = "v${version}";
|
2022-12-28 21:21:41 +00:00
|
|
|
sha256 = "sha256-4U/ChooesjhZSvxvk9dZrpZ/X0lf62+LEn72Ubrm2eM=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
# postPatch:
|
|
|
|
# screen.c: When run without a hardware accelerator, this allows the command to continue working rather than failing unexpectedly.
|
|
|
|
# This can happen when running on non-NixOS because then scrcpy seems to have a hard time using the host OpenGL-supporting hardware.
|
|
|
|
# It would be better to fix the OpenGL problem, but that seems much more intrusive.
|
|
|
|
postPatch = ''
|
|
|
|
substituteInPlace app/src/screen.c \
|
|
|
|
--replace "SDL_RENDERER_ACCELERATED" "SDL_RENDERER_ACCELERATED || SDL_RENDERER_SOFTWARE"
|
|
|
|
'';
|
|
|
|
|
2022-03-05 16:20:37 +00:00
|
|
|
nativeBuildInputs = [ makeWrapper meson ninja pkg-config installShellFiles ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2022-03-05 16:20:37 +00:00
|
|
|
buildInputs = [ ffmpeg SDL2 libusb1 ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
# Manually install the server jar to prevent Meson from "fixing" it
|
|
|
|
preConfigure = ''
|
|
|
|
echo -n > server/meson.build
|
|
|
|
'';
|
|
|
|
|
|
|
|
postInstall = ''
|
|
|
|
mkdir -p "$out/share/scrcpy"
|
|
|
|
ln -s "${prebuilt_server}" "$out/share/scrcpy/scrcpy-server"
|
|
|
|
|
|
|
|
# runtime dep on `adb` to push the server
|
|
|
|
wrapProgram "$out/bin/scrcpy" --prefix PATH : "${platform-tools}/bin"
|
2022-12-28 21:21:41 +00:00
|
|
|
'' + lib.optionalString stdenv.isLinux ''
|
|
|
|
substituteInPlace $out/share/applications/scrcpy-console.desktop \
|
|
|
|
--replace "/bin/bash" "${runtimeShell}"
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
2021-01-15 22:18:51 +00:00
|
|
|
meta = with lib; {
|
2020-04-24 23:36:52 +00:00
|
|
|
description = "Display and control Android devices over USB or TCP/IP";
|
|
|
|
homepage = "https://github.com/Genymobile/scrcpy";
|
2022-06-16 17:23:12 +00:00
|
|
|
sourceProvenance = with sourceTypes; [
|
|
|
|
fromSource
|
|
|
|
binaryBytecode # server
|
|
|
|
];
|
2020-04-24 23:36:52 +00:00
|
|
|
license = licenses.asl20;
|
|
|
|
platforms = platforms.unix;
|
2021-09-18 10:52:07 +00:00
|
|
|
maintainers = with maintainers; [ deltaevo lukeadams msfjarvis ];
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|