11{
2- lib ,
32 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 ,
711 i2c-tools ,
812 libX11 ,
913 libgpiod_1 ,
1014 libinput ,
1115 libusb1 ,
1216 libuv ,
1317 libxkbcommon ,
14- udevCheckHook ,
1518 ulfius ,
19+ openssl ,
20+ gnutls ,
21+ jansson ,
22+ zlib ,
23+ libmicrohttpd ,
24+ orcania ,
25+ yder ,
1626 yaml-cpp ,
27+ udevCheckHook ,
28+ versionCheckHook ,
29+ makeBinaryWrapper ,
30+ python3Packages ,
1731} :
32+ let
33+ version = "2.7.16.a597230" ;
34+
35+ platformio-deps-native = fetchzip {
36+ url = "https://github.com/meshtastic/firmware/releases/download/v${ version } /platformio-deps-native-tft-${ version } .zip" ;
37+ hash = "sha256-Jo7e6zsCaiJs6NyIRmD6BWJFwbs0xVlUih206ePUpwk=" ;
38+ } ;
39+ in
1840stdenv . mkDerivation ( finalAttrs : {
1941 pname = "meshtasticd" ;
20- version = "2.6.11.25" ;
42+ inherit version ;
2143
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=" ;
44+ src = fetchFromGitHub {
45+ owner = "meshtastic" ;
46+ repo = "firmware" ;
47+ hash = "sha256-oU3Z8qjBNeNGPGT74VStAPHgsGqsQJKngHJR6m2CBa0=" ;
48+ tag = "v${ finalAttrs . version } " ;
49+ fetchSubmodules = true ;
2550 } ;
2651
52+ strictDeps = true ;
53+
2754 nativeBuildInputs = [
28- autoPatchelfHook
29- dpkg
55+ libarchive
56+ pkg-config
57+ ( platformio-core . overridePythonAttrs ( oldAttrs : {
58+ dependencies = oldAttrs . dependencies ++ [
59+ python3Packages . grpcio-tools
60+ ] ;
61+ } ) )
62+ writableTmpDirAsHomeHook
63+ makeBinaryWrapper
3064 ] ;
3165
32- dontConfigure = true ;
33- dontBuild = true ;
34-
35- strictDeps = true ;
36-
3766 buildInputs = [
67+ bluez
68+ gnutls
3869 i2c-tools
70+ jansson
3971 libX11
4072 libgpiod_1
4173 libinput
74+ libmicrohttpd
4275 libusb1
4376 libuv
4477 libxkbcommon
78+ openssl
79+ orcania
4580 ulfius
4681 yaml-cpp
82+ yder
83+ zlib
4784 ] ;
4885
49- autoPatchelfIgnoreMissingDeps = [
50- "libyaml-cpp.so.0.7"
51- ] ;
86+ preConfigure = ''
87+ mkdir -p platformio-deps-native
88+ cp -ar ${ platformio-deps-native } /. platformio-deps-native
89+ chmod +w -R platformio-deps-native
90+
91+ export PLATFORMIO_CORE_DIR=platformio-deps-native/core
92+ export PLATFORMIO_LIBDEPS_DIR=platformio-deps-native/libdeps
93+ export PLATFORMIO_PACKAGES_DIR=platformio-deps-native/packages
94+ '' ;
95+
96+ buildPhase = ''
97+ runHook preBuild
98+
99+ platformio run --environment native-tft
100+
101+ runHook postBuild
102+ '' ;
52103
53104 installPhase = ''
54105 runHook preInstall
55106
56- mkdir -p {$out,$out/bin}
57- cp -r {usr,lib} $out/
107+ install -Dm644 bin/org.meshtastic.meshtasticd.svg -t $out/share/icons/hicolor/scalable/apps/
108+ install -Dm644 bin/org.meshtastic.meshtasticd.desktop -t $out/share/applications/
109+ install -Dm755 .pio/build/native-tft/program $out/bin/meshtasticd
110+
111+ wrapProgram $out/bin/meshtasticd \
112+ --add-flags "-c $out/share/meshtasticd/config.yaml"
58113
59- patchelf --replace-needed libyaml-cpp.so.0.7 libyaml-cpp.so.0.8 $out/usr/bin/meshtasticd
114+ install -Dm644 bin/config-dist.yaml $out/share/meshtasticd/config.yaml
115+ substituteInPlace $out/share/meshtasticd/config.yaml \
116+ --replace-fail "/etc/meshtasticd/config.d/" "$out/share/meshtasticd/config.d/" \
117+ --replace-fail "/etc/meshtasticd/available.d/" "$out/share/meshtasticd/available.d/"
60118
61- ln -s $out/usr/bin/meshtasticd $out/bin/meshtasticd
119+ install -d $out/share/meshtasticd/config.d
120+ install -d $out/share/meshtasticd/available.d
62121
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' ""
122+ cp -R bin/config.d/* $out/share/meshtasticd/available.d
123+
124+ install -Dm644 bin/config.d/MUI/X11_480x480.yaml $out/share/meshtasticd/config.d/MUI.yaml
125+
126+ install -d $out/share/meshtasticd/maps
127+
128+ for file in pio/libdeps/native-tft/meshtastic-device-ui/maps/*.zip; do
129+ bsdtar -xf "$file" --no-same-owner --strip-components=1 -C $out/share/meshtasticd/maps;
130+ done
131+
132+ install -Dm644 bin/99-meshtasticd-udev.rules -t $out/etc/udev/rules.d
67133
68134 runHook postInstall
69135 '' ;
70136
71137 doInstallCheck = true ;
72- nativeInstallCheckInputs = [ udevCheckHook ] ;
138+ nativeInstallCheckInputs = [
139+ udevCheckHook
140+ versionCheckHook
141+ ] ;
142+ versionCheckProgramArg = "--version" ;
143+ preVersionCheck = ''
144+ version="${ lib . versions . major finalAttrs . version } .${ lib . versions . minor finalAttrs . version } .${ lib . versions . patch finalAttrs . version } "
145+ '' ;
73146
74147 meta = {
75148 description = "Meshtastic daemon for communicating with Meshtastic devices" ;
@@ -81,8 +154,7 @@ stdenv.mkDerivation (finalAttrs: {
81154 homepage = "https://github.com/meshtastic/firmware" ;
82155 mainProgram = "meshtasticd" ;
83156 license = lib . licenses . gpl3Plus ;
84- platforms = [ "x86_64-linux" ] ;
85- sourceProvenance = with lib . sourceTypes ; [ binaryNativeCode ] ;
157+ platforms = lib . platforms . linux ;
86158 maintainers = with lib . maintainers ; [ drupol ] ;
87159 } ;
88160} )
0 commit comments