1{
2 stdenv,
3 lib,
4 fetchFromGitHub,
5 pkg-config,
6 zlib,
7 libusb1,
8 libGL,
9 qmake,
10 wrapGAppsHook3,
11 wrapQtAppsHook,
12 mkDerivation,
13
14 qttools,
15 qtbase,
16 qt3d,
17 qtsvg,
18 qtserialport,
19 qtdeclarative,
20 qtquickcontrols,
21 qtquickcontrols2,
22 qtgraphicaleffects,
23 qtwayland,
24 nix-update-script,
25}:
26let
27 pname = "qFlipper";
28 version = "1.3.3";
29 hash = "sha256-/Xzy+OA0Nl/UlSkOOZW2YsOHdJvS/7X3Z3ITkPByAOc=";
30 timestamp = "99999999999";
31 commit = "nix-${version}";
32
33in
34mkDerivation {
35 inherit pname version;
36
37 src = fetchFromGitHub {
38 owner = "flipperdevices";
39 repo = "qFlipper";
40 rev = version;
41 fetchSubmodules = true;
42 inherit hash;
43 };
44
45 nativeBuildInputs = [
46 pkg-config
47 qmake
48 qttools
49 wrapGAppsHook3
50 wrapQtAppsHook
51 ];
52
53 buildInputs = [
54 zlib
55 libusb1
56 libGL
57
58 qtbase
59 qt3d
60 qtsvg
61 qtserialport
62 qtdeclarative
63 qtquickcontrols
64 qtquickcontrols2
65 qtgraphicaleffects
66 ]
67 ++ lib.optionals (stdenv.hostPlatform.isLinux) [
68 qtwayland
69 ];
70
71 qmakeFlags = [
72 "DEFINES+=DISABLE_APPLICATION_UPDATES"
73 "CONFIG+=qtquickcompiler"
74 ];
75
76 dontWrapGApps = true;
77
78 postPatch = ''
79 substituteInPlace qflipper_common.pri \
80 --replace 'GIT_VERSION = unknown' 'GIT_VERSION = "${version}"' \
81 --replace 'GIT_TIMESTAMP = 0' 'GIT_TIMESTAMP = ${timestamp}' \
82 --replace 'GIT_COMMIT = unknown' 'GIT_COMMIT = "${commit}"'
83 cat qflipper_common.pri
84 '';
85
86 postInstall = ''
87 mkdir -p $out/bin
88 ${lib.optionalString stdenv.hostPlatform.isDarwin ''
89 cp qFlipper.app/Contents/MacOS/qFlipper $out/bin
90 ''}
91 cp qFlipper-cli $out/bin
92
93 mkdir -p $out/etc/udev/rules.d
94 cp installer-assets/udev/42-flipperzero.rules $out/etc/udev/rules.d/
95 '';
96
97 doInstallCheck = true;
98
99 passthru.updateScript = nix-update-script { };
100
101 meta = with lib; {
102 broken = stdenv.hostPlatform.isDarwin;
103 description = "Cross-platform desktop tool to manage your flipper device";
104 homepage = "https://flipperzero.one/";
105 license = licenses.gpl3Only;
106 maintainers = with maintainers; [ cab404 ];
107 platforms = [
108 "x86_64-linux"
109 "x86_64-darwin"
110 "aarch64-linux"
111 ]; # qtbase doesn't build yet on aarch64-darwin
112 };
113}