CycloneDDS depends on Linux-only libraries such as acl and cannot be
built on MacOS. Removing CycloneDDS from rmw-implementation
dependencies is OK, because there are other RMW implementations, which
build fine on MacOS. For example FastDDS, which is the default one.
The result of this change is that on MacOS one cannot switch to
CycloneDDS at run-time by selecting it in the RMW_IMPLEMENTATION
environment variable.
Specifically, this commit avoids to following error:
error: Package ‘acl-2.3.1’ in
/nix/store/.../pkgs/development/libraries/acl/default.nix:40 is
not available on the requested hostPlatform:
hostPlatform.config = "aarch64-apple-darwin"
This fixes the following error:
make[2]: *** No rule to make target
'/nix/store/03q8gn91mj95y5bqbcl90hyvmpqpz738-python3-3.11.7/lib/libpython3.11.so',
needed by
'rosidl_generator_py/builtin_interfaces/libbuiltin_interfaces__rosidl_generator_py.dylib'.
Stop.
The content of jazzy/overrides.nix is just a copy of
rolling/overrides.nix.
At least ros-core builds successfully (tested on files generated by
superflore today; not yet in this repo).
makes the derivation more pure, without this it leads to (gzclient:1568911): GLib-GIO-ERROR **: 15:37:29.803: No GSettings schemas are installed on the system, unless you happen to be lucky enough to have the right files in your environment
When not using flakes, you would immediately start using the latest
version of the nix-ros branch whenever I updated it, even if it hadn't
been tested or added to the cache yet. Now, it will match the flake
locked version by default even when not using flakes.
The purpose of ROS-specific version of buildEnv in this overlay is to
reduce the length of environment variables when using many ROS
packages. However, currently it works only for ROS 1 and not for
ROS 2. This commit is an attempt to fix that.
Although the change looks trivial, it took me multiple full days to
figure out what to change and how. The following is my understanding
of how handling of environment variables works in ROS 2 and in
nix-ros-overlay and why the change in this commit works. I'm not
completely sure that it's all correct so feel free to complain if not.
- Every ament_cmake ROS package contains a $out/share/*/local_setup.sh
script, generated by ament CMake macros, which is responsible for
setting environment variables required for proper function of the
package under ROS 2. Every package extends AMENT_PREFIX_PATH and it
may extend other variables such as PATH. The default prefix used for
extending the variables is specified at compile time and is equal to
package's Nix store path ($out).
- local_setup.sh files are sourced when building dependent ROS
packages. In nix-ros-overlay, this is accomplished by
ament-cmake-core-setup-hook, which is automatically propagated to
all dependents.
- ROS-specific buildEnv ensures that ROS packages are not further
propagated downstream but non-ROS packages are.
ament-cmake-core-setup-hook is a non-ROS package (it's a Nix native
package) so if any package in the buildEnv depends on it, it is
propagated out of buildEnv. Therefore dependents of the buildEnv
source all local_setup.sh files from the buildEnv (and from other
ROS packages outside of buildEnv, if there are any).
- The problem when sourcing local_setup.sh files now is the default
prefix built into them, which causes every package to have a
separate entry in the extended variables. However, if the file is
sourced with AMENT_CURRENT_PREFIX variable set, its value overrides
the default prefix. That's what we do in this commit. We set
AMENT_CURRENT_PREFIX to the store path of the sourced package; in
case of normal ROS packages it's equal to the default builtin
prefix, but in case of buildEnv, it's different and all packages in
the environment share the same prefix.
I'm testing this change with the following flake.nix:
{
inputs = {
nix-ros-overlay.url = "/path/to/repo/with/this/commit";
nixpkgs.follows = "nix-ros-overlay/nixpkgs";
};
outputs = { self, nixpkgs, nix-ros-overlay }:
let
pkgs = import nixpkgs {
system = "x86_64-linux";
overlays = [ nix-ros-overlay.overlays.default ];
};
rosDistro = pkgs.rosPackages.humble;
buildEnv = rosDistro.buildEnv {
paths = with rosDistro; [
demo-nodes-cpp
];
};
in
{
devShells.x86_64-linux.default = pkgs.mkShell {
name = "ros-env-test";
packages = [ buildEnv ];
};
packages.x86_64-linux = {
default = buildEnv;
inherit (rosDistro) demo-nodes-cpp;
};
};
}
Running `nix develop` and then:
echo $AMENT_PREFIX_PATH | tr : \\n | wc -l
without this commit returns 71 entries, while with this commit the
result in a single entry!
The error messages were as follows:
In file included from /build/rosbag2-release-release-humble-rosbag2_compression-0.15.9-1/src/rosbag2_compression/compression_options.cpp:18:
/build/rosbag2-release-release-humble-rosbag2_compression-0.15.9-1/include/rosbag2_compression/compression_options.hpp:29:6: warning: elaborated-type-specifier for a scoped enum must not use the 'class' keyword
29 | enum class ROSBAG2_COMPRESSION_PUBLIC CompressionMode: uint32_t
| ~~~~ ^~~~~
| -----
/build/rosbag2-release-release-humble-rosbag2_compression-0.15.9-1/include/rosbag2_compression/compression_options.hpp:29:54: error: found ':' in nested-name-specifier, expected '::'
29 | enum class ROSBAG2_COMPRESSION_PUBLIC CompressionMode: uint32_t
| ^
| ::
/build/rosbag2-release-release-humble-rosbag2_compression-0.15.9-1/include/rosbag2_compression/compression_options.hpp:29:39: error: 'CompressionMode' has not been declared
29 | enum class ROSBAG2_COMPRESSION_PUBLIC CompressionMode: uint32_t
| ^~~~~~~~~~~~~~~