|
1 | | -{ |
2 | | - lib, |
3 | | - stdenv, |
4 | | - fetchFromGitHub, |
5 | | - fetchzip, |
6 | | - imagemagick, |
7 | | - libgbm, |
8 | | - libdrm, |
9 | | - flutter338, |
10 | | - pulseaudio, |
11 | | - webkitgtk_4_1, |
12 | | - copyDesktopItems, |
13 | | - makeDesktopItem, |
14 | | - |
15 | | - callPackage, |
16 | | - vodozemac-wasm ? callPackage ./vodozemac-wasm.nix { flutter = flutter338; }, |
17 | | - |
18 | | - targetFlutterPlatform ? "linux", |
19 | | -}: |
| 1 | +{ lib, stdenv, fetchFromGitHub, fetchzip, imagemagick, libgbm, libdrm |
| 2 | +, flutter338, pulseaudio, webkitgtk_4_1, copyDesktopItems, makeDesktopItem |
| 3 | +, callPackage |
| 4 | +, vodozemac-wasm ? callPackage ./vodozemac-wasm.nix { flutter = flutter338; } |
| 5 | +, targetFlutterPlatform ? "linux", }: |
20 | 6 |
|
21 | 7 | let |
22 | | - libwebrtcRpath = lib.makeLibraryPath [ |
23 | | - libgbm |
24 | | - libdrm |
25 | | - ]; |
| 8 | + libwebrtcRpath = lib.makeLibraryPath [ libgbm libdrm ]; |
26 | 9 | pubspecLock = lib.importJSON ./pubspec.lock.json; |
27 | 10 | libwebrtc = fetchzip { |
28 | | - url = "https://github.com/flutter-webrtc/flutter-webrtc/releases/download/v1.1.0/libwebrtc.zip"; |
29 | | - sha256 = "sha256-lRfymTSfoNUtR5tSUiAptAvrrTwbB8p+SaYQeOevMzA="; |
| 11 | + url = |
| 12 | + "https://github.com/flutter-webrtc/flutter-webrtc/releases/download/v1.3.0/libwebrtc.zip"; |
| 13 | + sha256 = "sha256-lGvWAicdKbNdMZAQS9Qyxv737G/sBI/hKbge/Xw5bDM="; |
| 14 | + |
| 15 | + }; |
| 16 | +in flutter338.buildFlutterApplication (rec { |
| 17 | + pname = "uchar-${targetFlutterPlatform}"; |
| 18 | + version = "2.4.1"; |
| 19 | + |
| 20 | + src = ../.; |
| 21 | + |
| 22 | + inherit pubspecLock; |
| 23 | + |
| 24 | + gitHashes = { |
| 25 | + flutter_web_auth_2 = "sha256-3aci73SP8eXg6++IQTQoyS+erUUuSiuXymvR32sxHFw="; |
| 26 | + flutter_secure_storage_linux = |
| 27 | + "sha256-cFNHW7dAaX8BV7arwbn68GgkkBeiAgPfhMOAFSJWlyY="; |
| 28 | + }; |
| 29 | + |
| 30 | + inherit targetFlutterPlatform; |
| 31 | + |
| 32 | + flutterBuildFlags = [ |
| 33 | + # Required since v2.4.0 |
| 34 | + "--enable-experiment=dot-shorthands" |
| 35 | + ]; |
| 36 | + |
| 37 | + meta = { |
| 38 | + description = "Chat with your friends (matrix client)"; |
| 39 | + homepage = "https://uchar.im/"; |
| 40 | + license = lib.licenses.agpl3Plus; |
| 41 | + maintainers = with lib.maintainers; [ mkg20001 tebriel aleksana ]; |
| 42 | + badPlatforms = lib.platforms.darwin; |
| 43 | + } // lib.optionalAttrs (targetFlutterPlatform == "linux") { |
| 44 | + mainProgram = "uchar"; |
| 45 | + }; |
| 46 | +} // lib.optionalAttrs (targetFlutterPlatform == "linux") { |
| 47 | + nativeBuildInputs = [ imagemagick copyDesktopItems webkitgtk_4_1 ]; |
| 48 | + |
| 49 | + runtimeDependencies = [ pulseaudio ]; |
| 50 | + |
| 51 | + env.NIX_LDFLAGS = "-rpath-link ${libwebrtcRpath}"; |
| 52 | + |
| 53 | + desktopItems = [ |
| 54 | + (makeDesktopItem { |
| 55 | + name = "uchar"; |
| 56 | + exec = "uchar"; |
| 57 | + icon = "uchar"; |
| 58 | + desktopName = "uchar"; |
| 59 | + genericName = "Chat with your friends (matrix client)"; |
| 60 | + categories = [ "Chat" "Network" "InstantMessaging" ]; |
| 61 | + }) |
| 62 | + ]; |
| 63 | + |
| 64 | + customSourceBuilders = { |
| 65 | + flutter_webrtc = { version, src, ... }: |
| 66 | + stdenv.mkDerivation { |
| 67 | + pname = "flutter_webrtc"; |
| 68 | + inherit version src; |
| 69 | + inherit (src) passthru; |
| 70 | + |
| 71 | + postPatch = '' |
| 72 | + substituteInPlace third_party/CMakeLists.txt \ |
| 73 | + --replace-fail "\''${CMAKE_CURRENT_LIST_DIR}/downloads/libwebrtc.zip" ${libwebrtc} |
| 74 | + ln -s ${libwebrtc} third_party/libwebrtc |
| 75 | + ''; |
| 76 | + |
| 77 | + installPhase = '' |
| 78 | + runHook preInstall |
| 79 | +
|
| 80 | + mkdir $out |
| 81 | + cp -r ./* $out/ |
| 82 | +
|
| 83 | + runHook postInstall |
| 84 | + ''; |
| 85 | + }; |
30 | 86 | }; |
31 | | -in |
32 | | -flutter338.buildFlutterApplication ( |
33 | | - rec { |
34 | | - pname = "uchar-${targetFlutterPlatform}"; |
35 | | - version = "2.4.1"; |
36 | | - |
37 | | - src = lib.cleanSource ../.; |
38 | | - |
39 | | - inherit pubspecLock; |
40 | | - |
41 | | - gitHashes = { |
42 | | - flutter_web_auth_2 = "sha256-3aci73SP8eXg6++IQTQoyS+erUUuSiuXymvR32sxHFw="; |
43 | | - flutter_secure_storage_linux = "sha256-cFNHW7dAaX8BV7arwbn68GgkkBeiAgPfhMOAFSJWlyY="; |
44 | | - }; |
45 | | - |
46 | | - inherit targetFlutterPlatform; |
47 | | - |
48 | | - flutterBuildFlags = [ |
49 | | - # Required since v2.4.0 |
50 | | - "--enable-experiment=dot-shorthands" |
51 | | - ]; |
52 | | - |
53 | | - meta = { |
54 | | - description = "Chat with your friends (matrix client)"; |
55 | | - homepage = "https://fluffychat.im/"; |
56 | | - license = lib.licenses.agpl3Plus; |
57 | | - maintainers = with lib.maintainers; [ |
58 | | - mkg20001 |
59 | | - tebriel |
60 | | - aleksana |
61 | | - ]; |
62 | | - badPlatforms = lib.platforms.darwin; |
63 | | - } |
64 | | - // lib.optionalAttrs (targetFlutterPlatform == "linux") { |
65 | | - mainProgram = "uchar"; |
66 | | - }; |
67 | | - } |
68 | | - // lib.optionalAttrs (targetFlutterPlatform == "linux") { |
69 | | - nativeBuildInputs = [ |
70 | | - imagemagick |
71 | | - copyDesktopItems |
72 | | - webkitgtk_4_1 |
73 | | - ]; |
74 | | - |
75 | | - runtimeDependencies = [ pulseaudio ]; |
76 | | - |
77 | | - env.NIX_LDFLAGS = "-rpath-link ${libwebrtcRpath}"; |
78 | | - |
79 | | - desktopItems = [ |
80 | | - (makeDesktopItem { |
81 | | - name = "Uchar"; |
82 | | - exec = "Uchar"; |
83 | | - icon = "Uchar"; |
84 | | - desktopName = "Uchar"; |
85 | | - genericName = "Chat with your friends (matrix client)"; |
86 | | - categories = [ |
87 | | - "Chat" |
88 | | - "Network" |
89 | | - "InstantMessaging" |
90 | | - ]; |
91 | | - }) |
92 | | - ]; |
93 | | - |
94 | | - customSourceBuilders = { |
95 | | - flutter_webrtc = |
96 | | - { version, src, ... }: |
97 | | - stdenv.mkDerivation { |
98 | | - pname = "flutter_webrtc"; |
99 | | - inherit version src; |
100 | | - inherit (src) passthru; |
101 | | - |
102 | | - postPatch = '' |
103 | | - substituteInPlace third_party/CMakeLists.txt \ |
104 | | - --replace-fail "\''${CMAKE_CURRENT_LIST_DIR}/downloads/libwebrtc.zip" ${libwebrtc} |
105 | | - ln -s ${libwebrtc} third_party/libwebrtc |
106 | | - ''; |
107 | | - |
108 | | - installPhase = '' |
109 | | - runHook preInstall |
110 | | -
|
111 | | - mkdir $out |
112 | | - cp -r ./* $out/ |
113 | | -
|
114 | | - runHook postInstall |
115 | | - ''; |
116 | | - }; |
117 | | - }; |
118 | | - |
119 | | - # Temporary fix for json deprecation error |
120 | | - # https://github.com/juliansteenbakker/flutter_secure_storage/issues/965 |
121 | | - postPatch = '' |
122 | | - substituteInPlace linux/CMakeLists.txt \ |
123 | | - --replace-fail \ |
124 | | - "PRIVATE -Wall -Werror" \ |
125 | | - "PRIVATE -Wall -Werror -Wno-deprecated" |
126 | | - ''; |
127 | | - |
128 | | - postInstall = '' |
129 | | - FAV=$out/app/fluffychat-linux/data/flutter_assets/assets/favicon.png |
130 | | - ICO=$out/share/icons |
131 | | -
|
132 | | - for size in 24 32 42 64 128 256 512; do |
133 | | - D=$ICO/hicolor/''${size}x''${size}/apps |
134 | | - mkdir -p $D |
135 | | - magick $FAV -resize ''${size}x''${size} $D/fluffychat.png |
136 | | - done |
137 | | -
|
138 | | - patchelf --add-rpath ${libwebrtcRpath} $out/app/fluffychat-linux/lib/libwebrtc.so |
139 | | - ''; |
140 | | - } |
141 | | - // lib.optionalAttrs (targetFlutterPlatform == "web") { |
142 | | - preBuild = '' |
143 | | - cp -r ${vodozemac-wasm}/* ./assets/vodozemac/ |
144 | | - ''; |
145 | | - } |
146 | | -) |
| 87 | + |
| 88 | + # Temporary fix for json deprecation error |
| 89 | + # https://github.com/juliansteenbakker/flutter_secure_storage/issues/965 |
| 90 | + postPatch = '' |
| 91 | + substituteInPlace linux/CMakeLists.txt \ |
| 92 | + --replace-fail \ |
| 93 | + "PRIVATE -Wall -Werror" \ |
| 94 | + "PRIVATE -Wall -Werror -Wno-deprecated" |
| 95 | + ''; |
| 96 | + |
| 97 | + postInstall = '' |
| 98 | + FAV=$out/app/uchar-linux/data/flutter_assets/assets/favicon.png |
| 99 | + ICO=$out/share/icons |
| 100 | +
|
| 101 | + for size in 24 32 42 64 128 256 512; do |
| 102 | + D=$ICO/hicolor/''${size}x''${size}/apps |
| 103 | + mkdir -p $D |
| 104 | + magick $FAV -resize ''${size}x''${size} $D/uchar.png |
| 105 | + done |
| 106 | +
|
| 107 | + patchelf --add-rpath ${libwebrtcRpath} $out/app/uchar-linux/lib/libwebrtc.so |
| 108 | + ''; |
| 109 | +} // lib.optionalAttrs (targetFlutterPlatform == "web") { |
| 110 | + preBuild = '' |
| 111 | + cp -r ${vodozemac-wasm}/* ./assets/vodozemac/ |
| 112 | + ''; |
| 113 | +}) |
| 114 | + |
0 commit comments