Conversation
|
Zenoh is now part of nixpkgs see here, maybe we can use that here. I will test this in the next days. |
|
now zenoh-cpp-vendor is working but zenoh-bridge-dds does not compile completely and crashes with : |
|
update on zenoh-bridge-dds. If I check out version 1.2.1 from github it also builds, so I think a new release will fix that also. |
|
Yay, thanks for your work @muellerbernd! I was just trying to use zenoh as RMW in my devshell (via pkg With your branch, I can successfully use rmw zenoh. |
|
Here is my overlay to use zenoh, but I have to use a slightly out of date version from before the switch to zenoh-cpp rmw-zenoh-cpp = rosFinal.buildRosPackage {
pname = "ros-${ros}-rmw-zenoh-cpp";
inherit version;
src = ./vendored/rmw_zenoh/rmw_zenoh_cpp;
# Dep added directly, dont need vendor
postPatch = ''
sed -i '/zenoh_c_vendor/d' CMakeLists.txt
'';
buildType = "ament_cmake";
nativeBuildInputs = with rosFinal; [ ament-cmake ];
propagatedBuildInputs =
with final;
with rosFinal;
with rosFinal.python3.pkgs;
[
zenoh-c
rosidl-typesupport-fastrtps-c
rosidl-typesupport-fastrtps-cpp
rcutils
rcpputils
fastcdr
ament-index-cpp
rmw
];
};
zenoh-c = prev.stdenv.mkDerivation rec {
name = "zenoh-c";
pname = "zenoh-c";
src = prev.fetchFromGitHub rec {
name = "zenoh-c-${rev}"; # invalidate build if rev changes
owner = "eclipse-zenoh";
repo = "zenoh-c";
# parse exact git commit from the zenoh_c_vendor package
rev = builtins.elemAt (builtins.match ".*VCS_VERSION ([a-z0-9]+).*" (
builtins.readFile ./vendored/rmw_zenoh/zenoh_c_vendor/CMakeLists.txt
)) 0;
hash = "sha256-4MAytgYjBqpNeeTEFRTzT3deIg4YFVE+YJnzFEJPpCE=";
};
cargoDeps = prev.rustPlatform.importCargoLock {
lockFile = "${src}/Cargo.lock";
outputHashes = {
"zenoh-0.11.0-dev" = "sha256-UtOuH5CwOKj8ZSxnAwVlFfe5RrejAp87SN9xlkwam90=";
};
};
nativeBuildInputs = with prev; [
cmake
rustPlatform.cargoSetupHook
cargo
rustc
];
# Remove path building, as nix is already absolute paths
postPatch = ''
sed -i -e '/^preifx=.*/d' -e 's|[$]{prefix}/||' install/zenohc.pc.in
sed -i -e 's|[$]{_IMPORT_PREFIX}/||' install/PackageConfig.cmake.in
'';
};I hope it helps! Edit: I specifically have commit |
|
I have tried to update to newer versions of rmw_zenoh, but when building zenoh-cpp I get errors like below, even though I am building from the exact commits that are referenced in rmw_zenoh's vendors / zenoh-cpp's submodules. |
|
Related to my progress getting my overlay to work with updated rmw_zenoh ros2/rmw_zenoh#482 |
I have updated this PR to use updated version of rmw_zenoh |
…n check against upstream VCS_VERSION
|
Okay, I got this to work even with the newer versions of let
addRosPackages = ros: final: prev: rosFinal: rosPrev: {
rmw-zenoh-cpp = rosFinal.buildRosPackage {
pname = "ros-${ros}-rmw-zenoh-cpp";
version = "0.2.2";
src = ./vendored/rmw_zenoh/rmw_zenoh_cpp;
# Dep added directly, dont need vendor
postPatch = ''
substituteInPlace CMakeLists.txt --replace-fail \
"find_package(zenoh_cpp_vendor REQUIRED)" \
"find_package(zenohc REQUIRED)
find_package(zenohcxx REQUIRED)"
'';
cmakeArgs = [
"-DZENOHC_BUILD_WITH_UNSTABLE_API=TRUE"
"-DZENOHC_CARGO_FLAGS=--features=shared-memory,zenoh/transport_compression,zenoh/transport_tcp,zenoh/transport_tls"
];
buildType = "ament_cmake";
nativeBuildInputs = with rosFinal; [ ament-cmake ];
propagatedBuildInputs =
with final;
with rosFinal;
with rosFinal.python3.pkgs;
[
ament-index-cpp
fastcdr
rcpputils
rcutils
rmw
rosidl-typesupport-fastrtps-c
rosidl-typesupport-fastrtps-cpp
tracetools
zenoh-cpp
zenoh-c
];
};
};
in
(final: prev: rec {
zenoh-c = prev.stdenv.mkDerivation rec {
name = "${pname}-${src.rev}";
pname = "zenoh-c";
src = prev.fetchFromGitHub rec {
name = "${pname}-${rev}"; # invalidate build if rev changes
owner = "eclipse-zenoh";
repo = "zenoh-c";
# parse exact git commit from the zenoh_c_vendor package
rev = builtins.elemAt (builtins.match ".*zenoh-c\.git\n[ ]*VCS_VERSION ([a-z0-9]+).*" (builtins.readFile ./vendored/rmw_zenoh/zenoh_cpp_vendor/CMakeLists.txt)) 0;
hash = "ecf21d45edb870ca2d3e24d38503842081420766";
};
cargoDeps = prev.rustPlatform.importCargoLock {
lockFile = "${src}/Cargo.lock";
outputHashes = {
"zenoh-1.2.1" = "sha256-jtslgZxKKIhqNHOwZ38pjOn+zbnJSFnWejMnOQa8lv4";
};
};
cmakeFlags =
let
# Parse needed cargo feature flags from source, too
cargoFlags = builtins.elemAt (builtins.match ".*ZENOHC_CARGO_FLAGS \"(.+)\"\\).*" (builtins.readFile ./vendored/rmw_zenoh/zenoh_cpp_vendor/CMakeLists.txt)) 0;
in
[
"-DZENOHC_BUILD_WITH_UNSTABLE_API=TRUE"
"-DZENOHC_CARGO_FLAGS=${cargoFlags}"
];
nativeBuildInputs = with prev; [
cmake
rustPlatform.cargoSetupHook
cargo
rustc
];
# Remove path building, as nix is already absolute paths
postPatch = ''
sed -i -e '/^preifx=.*/d' -e 's|[$]{prefix}/||' install/zenohc.pc.in
sed -i -e 's|[$]{_IMPORT_PREFIX}/||' install/PackageConfig.cmake.in
'';
};
zenoh-cpp = prev.stdenv.mkDerivation rec {
name = "${pname}-${src.rev}";
pname = "zenoh-cpp";
src = prev.fetchFromGitHub rec {
name = "zenoh-cpp-${rev}"; # invalidate build if rev changes
owner = "eclipse-zenoh";
repo = "zenoh-cpp";
# parse exact git commit from the zenoh_cpp_vendor package
rev = builtins.elemAt (builtins.match ".*zenoh-cpp\n[ ]*VCS_VERSION ([a-z0-9]+).*" (builtins.readFile ./vendored/rmw_zenoh/zenoh_cpp_vendor/CMakeLists.txt)) 0;
hash = "sha256-8tuVs3NgUPmFuswFrOF8hZZWaOGRt2nwzoNScIWk9vE=";
};
nativeBuildInputs = with prev; [
cmake
];
buildInputs = [ zenoh-c ];
postPatch = ''
sed -i -e '/^preifx=.*/d' -e 's|[$]{prefix}/||' install/zenohcxx.pc.in
sed -i -e 's|[$]{_IMPORT_PREFIX}/||' install/PackageConfig.cmake.in
'';
};
rosPackages.jazzy = prev.rosPackages.jazzy.overrideScope (addRosPackages "jazzy" final prev);
rosPackages.rolling = prev.rosPackages.rolling.overrideScope (addRosPackages "rolling" final prev);
})Sorry, I ran into some issues testing this specifically with This could be a little hard to bundle into this repo, because there will have to be a set different Maybe @lopsided98 has some input on the best way to handle this. I think you do the most work in the overlays. But I do think it would be worth fixing the |
…keLists.txt with multiple amend_vendor's
|
@wentasah @lopsided98 I had to reintroduce the older version of |
|
Hi @muellerbernd! I just came across your work and wanted to express my gratitude for the great contributions you've made. I can confirm that everything works perfectly on my NixOS machine. 😊 |
…t_vendor calls This is needed at least for zenoh-cpp-vendor, which is being prepared in lopsided98#558. The format of vendored-source.json is changed from a single object to an array of objects. The order of objects corresponds to the order of ament_vendor calls in the patched CMakeLists.txt. ament_cmake_vendor_packageConfig.cmake was updated to generate such a format automatically and patchAmentVendorGit was updated to understand that format and patch all call sites in the correct order. The vendored-source.json files are regenerated automatically and there are no changes except addition of extra brackets.
|
@muellerbernd Sorry for breaking your PR. I tried to extend the new When I tried override like this, automatic patching worked: zenoh-cpp-vendor = lib.patchAmentVendorGit rosSuper.zenoh-cpp-vendor { };It will be needed to further override the result to patch the other things that you do in this PR. If you need the git hashes, you should be able to read them from |
I have tried to get it building in a testing branch but it is still WIP. |
|
I'm getting |
I get the same error. Right now I have no clue what's causing this. |
…t_vendor calls This is needed at least for zenoh-cpp-vendor, which is being prepared in lopsided98#558. The format of vendored-source.json is changed from a single object to an array of objects. The order of objects corresponds to the order of ament_vendor calls in the patched CMakeLists.txt. ament_cmake_vendor_packageConfig.cmake was updated to generate such a format automatically and patchAmentVendorGit was updated to understand that format and patch all call sites in the correct order. The vendored-source.json files are regenerated automatically and there are no changes except addition of extra brackets.
|
Hmm, it was my fault. I updated #620. With it, your overrides work. |
…t_vendor calls This is needed at least for zenoh-cpp-vendor, which is being prepared in lopsided98#558. The format of vendored-source.json is changed from a single object to an array of objects. The order of objects corresponds to the order of ament_vendor calls in the patched CMakeLists.txt. ament_cmake_vendor_packageConfig.cmake was updated to generate such a format automatically and patchAmentVendorGit was updated to understand that format and patch all call sites in the correct order. The vendored-source.json files are regenerated automatically and there are no changes except addition of extra brackets.
…t_vendor calls This is needed at least for zenoh-cpp-vendor, which is being prepared in lopsided98#558, but it also improves the robustness of the whole patching machanism. The format of vendored-source.json is changed from a single object to object of objects, one for each call to ament_vendor. The key in the top-level object is the target name specified in the ament_vendor call in CMakeLists.txt. The principle of operation is slightly different from the previous version. Instead of introducing "fake" ament_cmake_vendor_package just for creation of vendored-source.json, we introduce a "wrapped" version of ament_cmake_vendor_package, which is used both for creation of vendored-source.json as well as for compiling the package. When compiling the package, the wrapped version captures ament_vendor calls and modifies the arguments to use the prefetched data from the Nix store instead of downloading them directly. patchAmentVendorGit was updated to understand the new format and to invoke CMake with the wrapped package and information from vendored-source.json. The vendored-source.json files will be changed to the new format in the next commit.
|
@muellerbernd I've extracted overrides from your test branch and added them in #643 as af4ee83. I simplified the Nix expression a bit to take advantage of the fact that I've also removed overrides for |
@wentasah looks good to me. Thanks for your effort on getting also Kilted working with this overlay. @lopsided98 would be nice if you could give some feedback on this and the other mentioned PRs. |
| self.cargo | ||
| self.rustc | ||
| ]; | ||
| postPatch = postPatch + '' |
There was a problem hiding this comment.
Something like this currently works for me but to get it to cross-compile you need to set the define ZENOHC_CUSTOM_TARGET in the cmake flags. Something like this:
cmakeFlags = cmakeFlags ++
lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform)
[ "-DZENOHC_CUSTOM_TARGET=${stdenv.hostPlatform.config}" ];See: https://github.com/eclipse-zenoh/zenoh-c?tab=readme-ov-file#cross-compilation
…t_vendor calls This is needed at least for zenoh-cpp-vendor, which is being prepared in #558, but it also improves the robustness of the whole patching machanism. The format of vendored-source.json is changed from a single object to object of objects, one for each call to ament_vendor. The key in the top-level object is the target name specified in the ament_vendor call in CMakeLists.txt. The principle of operation is slightly different from the previous version. Instead of introducing "fake" ament_cmake_vendor_package just for creation of vendored-source.json, we introduce a "wrapped" version of ament_cmake_vendor_package, which is used both for creation of vendored-source.json as well as for compiling the package. When compiling the package, the wrapped version captures ament_vendor calls and modifies the arguments to use the prefetched data from the Nix store instead of downloading them directly. patchAmentVendorGit was updated to understand the new format and to invoke CMake with the wrapped package and information from vendored-source.json. The vendored-source.json files will be changed to the new format in the next commit.
|
closing in favor of #666 |
I have tested the somewhat new middleware rmw_zenoh in a local workspace. Now I try to get the corresponding nix packages running.
When try to build them:
nix build .\#jazzy.zenoh-cpp-vendor --accept-flake-configColcon gets invoked, then colcon executes cargo and cargo cannot download stuff because it is sandboxed. According to the nixpkgs manual we would have to set the
cargoDeps.I saw that in #501 was also done some work to build rust nodes.