nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at devShellTools-shell 137 lines 3.7 kB view raw
1{ 2 lib, 3 stdenv, 4 fetchFromGitHub, 5 cmake, 6 pkg-config, 7 libsForQt5, 8 scrcpy, 9 android-tools, 10 ffmpeg, 11 makeDesktopItem, 12 copyDesktopItems, 13}: 14 15stdenv.mkDerivation rec { 16 pname = "qtscrcpy"; 17 version = "3.3.1"; 18 19 src = 20 (fetchFromGitHub { 21 owner = "barry-ran"; 22 repo = "QtScrcpy"; 23 tag = "v${version}"; 24 hash = "sha256-kDeMgSIEIQxaTDR/QAcIaEmPjkmUKBsGyF8fISRzu1M="; 25 fetchSubmodules = true; 26 }).overrideAttrs 27 (_: { 28 GIT_CONFIG_COUNT = 1; 29 GIT_CONFIG_KEY_0 = "url.https://github.com/.insteadOf"; 30 GIT_CONFIG_VALUE_0 = "git@github.com:"; 31 }); 32 33 patches = [ 34 # remove vendored ffmpeg, adb and scrcpy-server 35 ./remove_vendors.patch 36 37 # remove predefined adb and scrcpy-server path 38 # we later set them in wrapper 39 ./remove_predefined_paths.patch 40 41 # remove avcodec_close which is deprecated in ffmpeg_7 42 # This doesn't affect functionality because 43 # it's followed by avcodec_free_context 44 ./remove_deprecated_avcodec_free_context.patch 45 ]; 46 47 postPatch = '' 48 substituteInPlace QtScrcpy/QtScrcpyCore/{include/QtScrcpyCoreDef.h,src/device/server/server.h} \ 49 --replace-fail 'serverVersion = "3.3.1"' 'serverVersion = "${scrcpy.version}"' 50 substituteInPlace QtScrcpy/util/config.cpp \ 51 --replace-fail 'COMMON_SERVER_VERSION_DEF "3.3.1"' 'COMMON_SERVER_VERSION_DEF "${scrcpy.version}"' 52 substituteInPlace QtScrcpy/audio/audiooutput.cpp \ 53 --replace-fail 'sndcpy.sh' "$out/share/qtscrcpy/sndcpy.sh" 54 substituteInPlace QtScrcpy/sndcpy/sndcpy.sh \ 55 --replace-fail 'ADB=./adb' "ADB=${lib.getExe' android-tools "adb"}" \ 56 --replace-fail 'SNDCPY_APK=sndcpy.apk' "SNDCPY_APK=$out/share/qtscrcpy/sndcpy.apk" 57 ''; 58 59 nativeBuildInputs = [ 60 cmake 61 pkg-config 62 libsForQt5.wrapQtAppsHook 63 copyDesktopItems 64 ]; 65 66 buildInputs = [ 67 scrcpy 68 # Upstream vendors ffmpeg_4 69 ffmpeg 70 ] 71 ++ (with libsForQt5; [ 72 qtbase 73 qtmultimedia 74 qtx11extras 75 ]); 76 77 env.NIX_CFLAGS_COMPILE = toString [ 78 "-Wno-error=sign-compare" 79 ]; 80 81 # Doesn't contain rule to install 82 installPhase = '' 83 runHook preInstall 84 85 pushd ../output/x64/Release 86 install -Dm755 QtScrcpy -t $out/bin 87 install -Dm755 sndcpy.sh -t $out/share/qtscrcpy 88 install -Dm644 sndcpy.apk -t $out/share/qtscrcpy 89 popd 90 91 install -Dm644 ../QtScrcpy/res/image/tray/logo.png $out/share/pixmaps/qtscrcpy.png 92 93 runHook postInstall 94 ''; 95 96 desktopItems = [ 97 (makeDesktopItem { 98 name = "QtScrcpy"; 99 exec = "QtScrcpy %U"; 100 icon = "qtscrcpy"; 101 desktopName = "QtScrcpy"; 102 genericName = "Android Display Control"; 103 categories = [ 104 "Utility" 105 "RemoteAccess" 106 ]; 107 }) 108 ]; 109 110 preFixup = '' 111 qtWrapperArgs+=( 112 --set QTSCRCPY_ADB_PATH ${lib.getExe' android-tools "adb"} 113 --set QTSCRCPY_SERVER_PATH ${scrcpy}/share/scrcpy/scrcpy-server 114 ) 115 ''; 116 117 meta = { 118 description = "Android real-time display control software"; 119 homepage = "https://github.com/barry-ran/QtScrcpy"; 120 license = lib.licenses.asl20; 121 maintainers = with lib.maintainers; [ 122 daru-san 123 aleksana 124 ]; 125 mainProgram = "QtScrcpy"; 126 platforms = with lib.platforms; linux ++ darwin ++ windows; 127 # needs some special handling on darwin as it generates .app bundle directly 128 badPlatforms = lib.platforms.darwin; 129 sourceProvenance = with lib.sourceTypes; [ 130 fromSource 131 # Still includes sndcpy.apk vendored in the same repo 132 # which will run on controlled Android device 133 # https://github.com/barry-ran/QtScrcpy/blob/master/QtScrcpy/sndcpy/sndcpy.apk 134 binaryBytecode 135 ]; 136 }; 137}