1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
|
{
lib,
stdenv,
fetchFromGitHub,
cmake,
pkg-config,
openssl,
zlib,
curl,
# Which slicer this build targets. Determines the OBN_CLIENT_TYPE CMake
# passes through, which in turn determines the expected filename/version
# scheme for the built plugin. Currently "orca_slicer" is the only target
# exercised by this flake's home-manager module, but the upstream project
# also builds for e.g. "bambu_studio" - see its CMakeLists.txt/Clients.cmake
# for the full list.
clientType ? "orca_slicer",
# The plugin ABI is versioned into the .so filename the slicer expects
# (libbambu_networking_<version>.so). Check yours with:
# jq -r '.app.network_plugin_version // "not set"' ~/.config/OrcaSlicer/OrcaSlicer.conf
# and pass that here (with .99 as the 4th component - see README) if it differs.
obnVersion ? "02.03.00.99",
}:
let
# Vendored deps the upstream CMakeLists normally fetches over the network
# at configure time via FetchContent. We pre-fetch them as normal Nix
# sources and hand CMake writable copies instead (see preConfigure),
# so the build stays sandboxed.
mosquittoSrc = fetchFromGitHub {
owner = "eclipse";
repo = "mosquitto";
rev = "v2.1.2"; # must match OBN_MOSQUITTO_GIT_TAG in CMakeLists.txt
hash = "sha256-Zl55yjuzQY2fyaKs/zLaJ7a3OONKTDQPaT+DpPURdZI=";
};
cjsonSrc = fetchFromGitHub {
owner = "DaveGamble";
repo = "cJSON";
rev = "v1.7.18"; # must match OBN_CJSON_GIT_TAG in CMakeLists.txt
hash = "sha256-UgUWc/+Zie2QNijxKK5GFe4Ypk97EidG8nTiiHhn5Ys=";
};
in
stdenv.mkDerivation {
pname = "open-bamboo-networking-${clientType}";
version = "1.1.0";
src = fetchFromGitHub {
owner = "ClusterM";
repo = "open-bamboo-networking";
rev = "v1.1.0";
hash = "sha256-bxkOwCnlKu2fA3cEiTZq15anSwLkuJIyko19wqul6Fw=";
};
nativeBuildInputs = [
cmake
pkg-config
];
buildInputs = [
openssl
zlib
curl
];
cmakeFlags = [
"-DOBN_CLIENT_TYPE=${clientType}"
"-DOBN_VERSION=${obnVersion}"
"-DOBN_BUILD_TESTS=OFF"
# This build never touches $HOME - see README.md for install steps.
"-DOBN_PATCH_CLIENT_CONF=OFF"
"-DFETCHCONTENT_FULLY_DISCONNECTED=ON"
];
# The build patches the vendored mosquitto/cJSON sources in place
# (VendorMosquittoEmbedPatch.cmake writes into libcommon/CMakeLists.txt
# etc.), so FETCHCONTENT_SOURCE_DIR_* can't point directly at the
# read-only fetchFromGitHub store paths. Copy them into a writable
# scratch dir first and point CMake there instead.
preConfigure = ''
mkdir -p _vendor/mosquitto _vendor/cjson
cp -r --no-preserve=mode,ownership ${mosquittoSrc}/. _vendor/mosquitto
cp -r --no-preserve=mode,ownership ${cjsonSrc}/. _vendor/cjson
chmod -R u+w _vendor
cmakeFlagsArray+=(
"-DFETCHCONTENT_SOURCE_DIR_ECLIPSE_MOSQUITTO=$(pwd)/_vendor/mosquitto"
"-DFETCHCONTENT_SOURCE_DIR_CJSON=$(pwd)/_vendor/cjson"
)
'';
# `cmake --install` (run automatically by the stdenv cmake hook) produces,
# under $out/plugins/:
# libbambu_networking_<obnVersion>.so - LAN discovery/print/MQTT
# libBambuSource.so - camera/live-view tunnel
# liblive555.so - OTA-banner-check stub only,
# see README before installing
postInstall = ''
mkdir -p $out/lib
ln -s $out/plugins/libbambu_networking_${obnVersion}.so \
$out/lib/libbambu_networking_${obnVersion}.so
'';
# Read this back from downstream (README examples, activation scripts)
# instead of repeating the version string everywhere.
passthru = {
inherit obnVersion clientType;
};
meta = with lib; {
description = "Open-source drop-in replacement for Bambu Lab slicers' proprietary bambu_networking plugin (client: ${clientType})";
homepage = "https://github.com/ClusterM/open-bamboo-networking";
license = licenses.agpl3Plus;
platforms = platforms.linux;
};
}
|