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
|
2020-04-24 23:36:52 +00:00
|
|
|
, fetchpatch
|
|
|
|
|
|
|
|
, platform-tools
|
2020-08-20 17:08:02 +00:00
|
|
|
, ffmpeg
|
2020-04-24 23:36:52 +00:00
|
|
|
, SDL2
|
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
2021-02-05 17:12:51 +00:00
|
|
|
version = "1.17";
|
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}";
|
2021-02-05 17:12:51 +00:00
|
|
|
sha256 = "sha256-EbWtLRvJuXMPtyVKeO/XGo/0axk4/0aOR6IbZTobZyU=";
|
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}";
|
2021-02-05 17:12:51 +00:00
|
|
|
sha256 = "sha256-xCzrbWhMve0bJerFNHiUdSzp5O1pSaKRkcJSs/0nHpk=";
|
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"
|
|
|
|
'';
|
|
|
|
|
2020-05-29 06:06:01 +00:00
|
|
|
nativeBuildInputs = [ makeWrapper meson ninja pkg-config ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2020-08-20 17:08:02 +00:00
|
|
|
buildInputs = [ ffmpeg SDL2 ];
|
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
|
|
|
|
'';
|
|
|
|
|
|
|
|
mesonFlags = [ "-Doverride_server_path=${prebuilt_server}" ];
|
|
|
|
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"
|
|
|
|
'';
|
|
|
|
|
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";
|
|
|
|
license = licenses.asl20;
|
|
|
|
platforms = platforms.unix;
|
|
|
|
maintainers = with maintainers; [ deltaevo lukeadams ];
|
|
|
|
};
|
|
|
|
}
|