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
|
|
|
|
|
|
|
, 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-02-10 20:34:41 +00:00
|
|
|
version = "1.22";
|
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-02-10 20:34:41 +00:00
|
|
|
sha256 = "sha256-wF0nPux1M8DhBiguAlTPBOf16PDCkgyjlEiGX6sqQZs=";
|
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-02-10 20:34:41 +00:00
|
|
|
sha256 = "sha256-bYLvrCw6NNCZqgLWIEObnytgD74cE9pm/Z7dgB8S5x0=";
|
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
|
|
|
|
2021-12-06 16:07:01 +00:00
|
|
|
buildInputs = [ ffmpeg SDL2 ] ++ lib.optionals stdenv.isLinux [
|
|
|
|
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"
|
|
|
|
'';
|
|
|
|
|
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;
|
2021-09-18 10:52:07 +00:00
|
|
|
maintainers = with maintainers; [ deltaevo lukeadams msfjarvis ];
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|