|
1 | 1 | { |
2 | | - lib, |
3 | 2 | stdenv, |
4 | | - fetchurl, |
5 | | - autoPatchelfHook, |
6 | | - dpkg, |
| 3 | + lib, |
| 4 | + fetchFromGitHub, |
| 5 | + fetchzip, |
| 6 | + libarchive, |
| 7 | + pkg-config, |
| 8 | + platformio-core, |
| 9 | + writableTmpDirAsHomeHook, |
| 10 | + bluez, |
7 | 11 | i2c-tools, |
8 | 12 | libX11, |
9 | 13 | libgpiod_1, |
10 | 14 | libinput, |
11 | 15 | libusb1, |
12 | 16 | libuv, |
13 | 17 | libxkbcommon, |
14 | | - udevCheckHook, |
15 | 18 | ulfius, |
| 19 | + openssl, |
| 20 | + gnutls, |
| 21 | + jansson, |
| 22 | + zlib, |
| 23 | + libmicrohttpd, |
| 24 | + orcania, |
| 25 | + yder, |
16 | 26 | yaml-cpp, |
| 27 | + udevCheckHook, |
| 28 | + versionCheckHook, |
| 29 | + makeBinaryWrapper, |
| 30 | + python3Packages, |
| 31 | + withDefaultConfig ? false, |
| 32 | + meshtastic-web, # Only used if `withDefaultConfig` is set to `true`. |
17 | 33 | }: |
| 34 | +let |
| 35 | + version = "2.7.16.a597230"; |
| 36 | + |
| 37 | + platformio-deps-native = fetchzip { |
| 38 | + url = "https://github.com/meshtastic/firmware/releases/download/v${version}/platformio-deps-native-tft-${version}.zip"; |
| 39 | + hash = "sha256-Jo7e6zsCaiJs6NyIRmD6BWJFwbs0xVlUih206ePUpwk="; |
| 40 | + }; |
| 41 | +in |
18 | 42 | stdenv.mkDerivation (finalAttrs: { |
19 | 43 | pname = "meshtasticd"; |
20 | | - version = "2.6.11.25"; |
| 44 | + inherit version; |
21 | 45 |
|
22 | | - src = fetchurl { |
23 | | - url = "https://download.opensuse.org/repositories/network:/Meshtastic:/beta/Debian_12/amd64/meshtasticd_${finalAttrs.version}~obs60ec05e~beta_amd64.deb"; |
24 | | - hash = "sha256-7JCv+1YgsCLwboGE/2f+8iyLLoUsKn3YdJ9Atnfj7Zw="; |
| 46 | + src = fetchFromGitHub { |
| 47 | + owner = "meshtastic"; |
| 48 | + repo = "firmware"; |
| 49 | + hash = "sha256-oU3Z8qjBNeNGPGT74VStAPHgsGqsQJKngHJR6m2CBa0="; |
| 50 | + tag = "v${finalAttrs.version}"; |
| 51 | + fetchSubmodules = true; |
25 | 52 | }; |
26 | 53 |
|
| 54 | + strictDeps = true; |
| 55 | + |
27 | 56 | nativeBuildInputs = [ |
28 | | - autoPatchelfHook |
29 | | - dpkg |
| 57 | + libarchive |
| 58 | + pkg-config |
| 59 | + # This has been advised by the Meshtastic's developer. |
| 60 | + # Without it, it will try to install grpcio-tools by itself and fail. |
| 61 | + (platformio-core.overridePythonAttrs (oldAttrs: { |
| 62 | + dependencies = oldAttrs.dependencies ++ [ |
| 63 | + python3Packages.grpcio-tools |
| 64 | + ]; |
| 65 | + })) |
| 66 | + writableTmpDirAsHomeHook |
| 67 | + makeBinaryWrapper |
30 | 68 | ]; |
31 | 69 |
|
32 | | - dontConfigure = true; |
33 | | - dontBuild = true; |
34 | | - |
35 | | - strictDeps = true; |
36 | | - |
37 | 70 | buildInputs = [ |
| 71 | + bluez |
| 72 | + gnutls |
38 | 73 | i2c-tools |
| 74 | + jansson |
39 | 75 | libX11 |
40 | 76 | libgpiod_1 |
41 | 77 | libinput |
| 78 | + libmicrohttpd |
42 | 79 | libusb1 |
43 | 80 | libuv |
44 | 81 | libxkbcommon |
| 82 | + openssl |
| 83 | + orcania |
45 | 84 | ulfius |
46 | 85 | yaml-cpp |
| 86 | + yder |
| 87 | + zlib |
47 | 88 | ]; |
48 | 89 |
|
49 | | - autoPatchelfIgnoreMissingDeps = [ |
50 | | - "libyaml-cpp.so.0.7" |
51 | | - ]; |
| 90 | + preConfigure = '' |
| 91 | + mkdir -p platformio-deps-native |
| 92 | + cp -ar ${platformio-deps-native}/. platformio-deps-native |
| 93 | + chmod +w -R platformio-deps-native |
| 94 | +
|
| 95 | + export PLATFORMIO_CORE_DIR=platformio-deps-native/core |
| 96 | + export PLATFORMIO_LIBDEPS_DIR=platformio-deps-native/libdeps |
| 97 | + export PLATFORMIO_PACKAGES_DIR=platformio-deps-native/packages |
| 98 | + ''; |
| 99 | + |
| 100 | + buildPhase = '' |
| 101 | + runHook preBuild |
| 102 | +
|
| 103 | + platformio run --environment native-tft |
| 104 | +
|
| 105 | + runHook postBuild |
| 106 | + ''; |
52 | 107 |
|
53 | 108 | installPhase = '' |
54 | 109 | runHook preInstall |
55 | 110 |
|
56 | | - mkdir -p {$out,$out/bin} |
57 | | - cp -r {usr,lib} $out/ |
58 | | -
|
59 | | - patchelf --replace-needed libyaml-cpp.so.0.7 libyaml-cpp.so.0.8 $out/usr/bin/meshtasticd |
| 111 | + install -d $out/share/meshtasticd/config.d |
| 112 | + install -d $out/share/meshtasticd/available.d |
| 113 | + cp -R bin/config.d/* $out/share/meshtasticd/available.d |
60 | 114 |
|
61 | | - ln -s $out/usr/bin/meshtasticd $out/bin/meshtasticd |
| 115 | + install -Dm644 bin/org.meshtastic.meshtasticd.svg -t $out/share/icons/hicolor/scalable/apps/ |
| 116 | + install -Dm644 bin/org.meshtastic.meshtasticd.desktop -t $out/share/applications/ |
| 117 | + install -Dm755 .pio/build/native-tft/program $out/bin/meshtasticd |
62 | 118 |
|
63 | | - substituteInPlace $out/lib/systemd/system/meshtasticd.service \ |
64 | | - --replace-fail "/usr/bin/meshtasticd" "$out/bin/meshtasticd" \ |
65 | | - --replace-fail 'User=meshtasticd' 'DynamicUser=yes' \ |
66 | | - --replace-fail 'Group=meshtasticd' "" |
| 119 | + install -Dm644 bin/99-meshtasticd-udev.rules -t $out/etc/udev/rules.d |
| 120 | + '' |
| 121 | + + lib.optionalString withDefaultConfig '' |
| 122 | + install -Dm644 bin/config-dist.yaml $out/share/meshtasticd/config.yaml |
| 123 | + substituteInPlace $out/share/meshtasticd/config.yaml \ |
| 124 | + --replace-fail "/etc/meshtasticd/config.d" "$out/share/meshtasticd/config.d" \ |
| 125 | + --replace-fail "/etc/meshtasticd/available.d" "$out/share/meshtasticd/available.d" |
| 126 | + wrapProgram $out/bin/meshtasticd \ |
| 127 | + --add-flags "-c $out/share/meshtasticd/config.yaml" |
| 128 | + install -Dm644 bin/config.d/MUI/X11_480x480.yaml $out/share/meshtasticd/config.d/MUI.yaml |
| 129 | + substituteInPlace $out/share/meshtasticd/config.yaml \ |
| 130 | + --replace-fail "/usr/share/meshtasticd/web" "${meshtastic-web}" |
67 | 131 |
|
| 132 | + install -d $out/share/meshtasticd/maps |
| 133 | + for file in pio/libdeps/native-tft/meshtastic-device-ui/maps/*.zip; do |
| 134 | + bsdtar -xf "$file" --no-same-owner --strip-components=1 -C $out/share/meshtasticd/maps; |
| 135 | + done |
| 136 | + '' |
| 137 | + + '' |
68 | 138 | runHook postInstall |
69 | 139 | ''; |
70 | 140 |
|
71 | 141 | doInstallCheck = true; |
72 | | - nativeInstallCheckInputs = [ udevCheckHook ]; |
| 142 | + nativeInstallCheckInputs = [ |
| 143 | + udevCheckHook |
| 144 | + versionCheckHook |
| 145 | + ]; |
| 146 | + versionCheckProgramArg = "--version"; |
| 147 | + preVersionCheck = '' |
| 148 | + version="${lib.versions.major finalAttrs.version}.${lib.versions.minor finalAttrs.version}.${lib.versions.patch finalAttrs.version}" |
| 149 | + ''; |
73 | 150 |
|
74 | 151 | meta = { |
75 | 152 | description = "Meshtastic daemon for communicating with Meshtastic devices"; |
76 | 153 | longDescription = '' |
77 | 154 | This package has `udev` rules installed as part of the package. |
78 | 155 | Add `services.udev.packages = [ pkgs.meshtasticd ]` into your NixOS |
79 | 156 | configuration to enable them. |
| 157 | +
|
| 158 | + To enable the default configuration, set the `withDefaultConfig` parameter to true. |
80 | 159 | ''; |
81 | 160 | homepage = "https://github.com/meshtastic/firmware"; |
82 | 161 | mainProgram = "meshtasticd"; |
83 | 162 | license = lib.licenses.gpl3Plus; |
84 | | - platforms = [ "x86_64-linux" ]; |
85 | | - sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ]; |
| 163 | + platforms = lib.platforms.linux; |
86 | 164 | maintainers = with lib.maintainers; [ drupol ]; |
87 | 165 | }; |
88 | 166 | }) |
0 commit comments