ripasso-cursive: cosmetic changes (#361736)
[NixPkgs.git] / pkgs / by-name / qt / qtscrcpy / package.nix
blob3d9d733de46de7c1adc031421fcc51d29b512b55
2   lib,
3   stdenv,
4   fetchFromGitHub,
5   cmake,
6   pkg-config,
7   libsForQt5,
8   scrcpy,
9   android-tools,
10   ffmpeg,
11   makeDesktopItem,
12   copyDesktopItems,
15 stdenv.mkDerivation rec {
16   pname = "qtscrcpy";
17   version = "2.2.1";
19   src =
20     (fetchFromGitHub {
21       owner = "barry-ran";
22       repo = "QtScrcpy";
23       rev = "refs/tags/v${version}";
24       hash = "sha256-PL/UvRNqvLaFuvSHbkJsaJ2nqRp5+ERM+rmlKVtbShk=";
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       });
33   patches = [
34     # remove vendored ffmpeg, adb and scrcpy-server
35     ./remove_vendors.patch
37     # remove predefined adb and scrcpy-server path
38     # we later set them in wrapper
39     ./remove_predefined_paths.patch
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   ];
47   postPatch = ''
48     substituteInPlace QtScrcpy/QtScrcpyCore/{include/QtScrcpyCoreDef.h,src/device/server/server.h} \
49       --replace-fail 'serverVersion = "2.1.1"' 'serverVersion = "${scrcpy.version}"'
50     substituteInPlace QtScrcpy/util/config.cpp \
51       --replace-fail 'COMMON_SERVER_VERSION_DEF "2.1.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   '';
59   nativeBuildInputs = [
60     cmake
61     pkg-config
62     libsForQt5.wrapQtAppsHook
63     copyDesktopItems
64   ];
66   buildInputs =
67     [
68       scrcpy
69       # Upstream vendors ffmpeg_4
70       ffmpeg
71     ]
72     ++ (with libsForQt5; [
73       qtbase
74       qtmultimedia
75       qtx11extras
76     ]);
78   env.NIX_CFLAGS_COMPILE = toString [
79     "-Wno-error=sign-compare"
80   ];
82   # Doesn't contain rule to install
83   installPhase = ''
84     runHook preInstall
86     pushd ../output/x64/Release
87       install -Dm755 QtScrcpy -t $out/bin
88       install -Dm755 sndcpy.sh -t $out/share/qtscrcpy
89       install -Dm644 sndcpy.apk -t $out/share/qtscrcpy
90     popd
92     install -Dm644 ../QtScrcpy/res/image/tray/logo.png $out/share/pixmaps/qtscrcpy.png
94     runHook postInstall
95   '';
97   desktopItems = [
98     (makeDesktopItem {
99       name = "QtScrcpy";
100       exec = "QtScrcpy %U";
101       icon = "qtscrcpy";
102       desktopName = "QtScrcpy";
103       genericName = "Android Display Control";
104       categories = [
105         "Utility"
106         "RemoteAccess"
107       ];
108     })
109   ];
111   preFixup = ''
112     qtWrapperArgs+=(
113       --set QTSCRCPY_ADB_PATH ${lib.getExe' android-tools "adb"}
114       --set QTSCRCPY_SERVER_PATH ${scrcpy}/share/scrcpy/scrcpy-server
115     )
116   '';
118   meta = {
119     description = "Android real-time display control software";
120     homepage = "https://github.com/barry-ran/QtScrcpy";
121     license = lib.licenses.asl20;
122     maintainers = with lib.maintainers; [
123       daru-san
124       aleksana
125     ];
126     mainProgram = "QtScrcpy";
127     platforms = with lib.platforms; linux ++ darwin ++ windows;
128     # needs some special handling on darwin as it generates .app bundle directly
129     badPlatforms = lib.platforms.darwin;
130     sourceProvenance = with lib.sourceTypes; [
131       fromSource
132       # Still includes sndcpy.apk vendored in the same repo
133       # which will run on controlled Android device
134       # https://github.com/barry-ran/QtScrcpy/blob/master/QtScrcpy/sndcpy/sndcpy.apk
135       binaryBytecode
136     ];
137   };