|
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 | + (platformio-core.overridePythonAttrs (oldAttrs: { |
| 60 | + dependencies = oldAttrs.dependencies ++ [ |
| 61 | + python3Packages.grpcio-tools |
| 62 | + ]; |
| 63 | + })) |
| 64 | + writableTmpDirAsHomeHook |
| 65 | + makeBinaryWrapper |
30 | 66 | ]; |
31 | 67 |
|
32 | | - dontConfigure = true; |
33 | | - dontBuild = true; |
34 | | - |
35 | | - strictDeps = true; |
36 | | - |
37 | 68 | buildInputs = [ |
| 69 | + bluez |
| 70 | + gnutls |
38 | 71 | i2c-tools |
| 72 | + jansson |
39 | 73 | libX11 |
40 | 74 | libgpiod_1 |
41 | 75 | libinput |
| 76 | + libmicrohttpd |
42 | 77 | libusb1 |
43 | 78 | libuv |
44 | 79 | libxkbcommon |
| 80 | + openssl |
| 81 | + orcania |
45 | 82 | ulfius |
46 | 83 | yaml-cpp |
| 84 | + yder |
| 85 | + zlib |
47 | 86 | ]; |
48 | 87 |
|
49 | | - autoPatchelfIgnoreMissingDeps = [ |
50 | | - "libyaml-cpp.so.0.7" |
51 | | - ]; |
| 88 | + preConfigure = '' |
| 89 | + mkdir -p platformio-deps-native |
| 90 | + cp -ar ${platformio-deps-native}/. platformio-deps-native |
| 91 | + chmod +w -R platformio-deps-native |
| 92 | +
|
| 93 | + export PLATFORMIO_CORE_DIR=platformio-deps-native/core |
| 94 | + export PLATFORMIO_LIBDEPS_DIR=platformio-deps-native/libdeps |
| 95 | + export PLATFORMIO_PACKAGES_DIR=platformio-deps-native/packages |
| 96 | + ''; |
| 97 | + |
| 98 | + buildPhase = '' |
| 99 | + runHook preBuild |
| 100 | +
|
| 101 | + platformio run --environment native-tft |
| 102 | +
|
| 103 | + runHook postBuild |
| 104 | + ''; |
52 | 105 |
|
53 | 106 | installPhase = '' |
54 | 107 | runHook preInstall |
55 | 108 |
|
56 | | - mkdir -p {$out,$out/bin} |
57 | | - cp -r {usr,lib} $out/ |
| 109 | + install -d $out/share/meshtasticd/config.d |
| 110 | + install -d $out/share/meshtasticd/available.d |
| 111 | + cp -R bin/config.d/* $out/share/meshtasticd/available.d |
58 | 112 |
|
59 | | - patchelf --replace-needed libyaml-cpp.so.0.7 libyaml-cpp.so.0.8 $out/usr/bin/meshtasticd |
| 113 | + install -Dm644 bin/org.meshtastic.meshtasticd.svg -t $out/share/icons/hicolor/scalable/apps/ |
| 114 | + install -Dm644 bin/org.meshtastic.meshtasticd.desktop -t $out/share/applications/ |
| 115 | + install -Dm755 .pio/build/native-tft/program $out/bin/meshtasticd |
60 | 116 |
|
61 | | - ln -s $out/usr/bin/meshtasticd $out/bin/meshtasticd |
62 | | -
|
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' "" |
| 117 | + install -Dm644 bin/99-meshtasticd-udev.rules -t $out/etc/udev/rules.d |
| 118 | + '' |
| 119 | + + lib.optionalString withDefaultConfig '' |
| 120 | + install -Dm644 bin/config-dist.yaml $out/share/meshtasticd/config.yaml |
| 121 | + substituteInPlace $out/share/meshtasticd/config.yaml \ |
| 122 | + --replace-fail "/etc/meshtasticd/config.d" "$out/share/meshtasticd/config.d" \ |
| 123 | + --replace-fail "/etc/meshtasticd/available.d" "$out/share/meshtasticd/available.d" |
| 124 | + wrapProgram $out/bin/meshtasticd \ |
| 125 | + --add-flags "-c $out/share/meshtasticd/config.yaml" |
| 126 | + install -Dm644 bin/config.d/MUI/X11_480x480.yaml $out/share/meshtasticd/config.d/MUI.yaml |
| 127 | + substituteInPlace $out/share/meshtasticd/config.yaml \ |
| 128 | + --replace-fail "/usr/share/meshtasticd/web" "${meshtastic-web}" |
67 | 129 |
|
| 130 | + install -d $out/share/meshtasticd/maps |
| 131 | + for file in pio/libdeps/native-tft/meshtastic-device-ui/maps/*.zip; do |
| 132 | + bsdtar -xf "$file" --no-same-owner --strip-components=1 -C $out/share/meshtasticd/maps; |
| 133 | + done |
| 134 | + '' |
| 135 | + + '' |
68 | 136 | runHook postInstall |
69 | 137 | ''; |
70 | 138 |
|
71 | 139 | doInstallCheck = true; |
72 | | - nativeInstallCheckInputs = [ udevCheckHook ]; |
| 140 | + nativeInstallCheckInputs = [ |
| 141 | + udevCheckHook |
| 142 | + versionCheckHook |
| 143 | + ]; |
| 144 | + versionCheckProgramArg = "--version"; |
| 145 | + preVersionCheck = '' |
| 146 | + version="${lib.versions.major finalAttrs.version}.${lib.versions.minor finalAttrs.version}.${lib.versions.patch finalAttrs.version}" |
| 147 | + ''; |
73 | 148 |
|
74 | 149 | meta = { |
75 | 150 | description = "Meshtastic daemon for communicating with Meshtastic devices"; |
76 | 151 | longDescription = '' |
77 | 152 | This package has `udev` rules installed as part of the package. |
78 | 153 | Add `services.udev.packages = [ pkgs.meshtasticd ]` into your NixOS |
79 | 154 | configuration to enable them. |
| 155 | +
|
| 156 | + To enable the default configuration, set the `withDefaultConfig` parameter to true. |
| 157 | +
|
| 158 | + To enable the Meshtastic webserver files, set the `withWeb` 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