From 956be69b1a654a0a8ff3982bcf664aa5e57a7acf Mon Sep 17 00:00:00 2001 From: Maximilien Naveau Date: Thu, 9 Jan 2025 14:09:25 +0100 Subject: [PATCH] Add plot-juggler and protobuf with the correct version --- .envrc | 3 ++- .gitignore | 1 + flake.nix | 34 +++++++++++++++++++++++++++++++--- 3 files changed, 34 insertions(+), 4 deletions(-) diff --git a/.envrc b/.envrc index 6d5f841..5695ca3 100644 --- a/.envrc +++ b/.envrc @@ -1,3 +1,4 @@ +export RMW_IMPLEMENTATION=rmw_fastrtps_cpp if test -f .envrc.local; then # If you don't need nixgl, eg. if you are n NixOS, you can: # echo 'use flake .#pure' > .envrc.local @@ -5,5 +6,5 @@ if test -f .envrc.local; then else # unfree is only required if you use nvidia export NIXPKGS_ALLOW_UNFREE=1 - use flake . --impure + use flake . --impure fi diff --git a/.gitignore b/.gitignore index 159d697..06c6b47 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ .envrc.local result* +.direnv \ No newline at end of file diff --git a/flake.nix b/flake.nix index 37d22dd..f032f34 100644 --- a/flake.nix +++ b/flake.nix @@ -14,8 +14,8 @@ ## NixGL, for people not yet on NixOS nixgl.url = "github:nix-community/nixGL"; }; - outputs = - { nixpkgs, self, ... }@inputs: + + outputs = { nixpkgs, self, ... }@inputs: inputs.nix-ros-overlay.inputs.flake-utils.lib.eachDefaultSystem ( system: let @@ -24,6 +24,10 @@ overlays = [ inputs.nix-ros-overlay.overlays.default inputs.nixgl.overlay + (final: prev: { + # Override protobuf version to ensure compatibility + protobuf = prev.protobuf3_21; + }) ]; patches = [ inputs.patch-hpp @@ -34,6 +38,19 @@ self.packages.${system}.python self.packages.${system}.ros ]; + # Precompute the BASE_DIR path + baseDir = pkgs.python3Packages.example-robot-data.outPath; + # Define the shared shell hook, referencing the precomputed path + sharedShellHook = '' + if [ -z "$BASE_DIR" ]; then + echo "Error: Could not locate the example-robot-data package." >&2 + else + SHARE_DIR=$BASE_DIR + export AMENT_PREFIX_PATH=$SHARE_DIR:$AMENT_PREFIX_PATH + export ROS_PACKAGE_PATH=$SHARE_DIR/share:$ROS_PACKAGE_PATH + echo "Added $SHARE_DIR to AMENT_PREFIX_PATH and ROS_PACKAGE_PATH" + fi + ''; in { devShells = { @@ -44,10 +61,18 @@ packages = pure-packages ++ [ self.packages.${system}.nixgl-gepetto-gui ]; + shellHook = '' + export BASE_DIR='${baseDir}' + ${sharedShellHook} + ''; }; pure = pkgs.mkShell { name = "Gepetto Main Dev Shell"; packages = pure-packages; + shellHook = '' + export BASE_DIR='${baseDir}' + ${sharedShellHook} + ''; }; }; packages = { @@ -67,7 +92,10 @@ buildEnv { paths = [ ros-core - turtlesim + rmw-fastrtps-cpp + rmw-cyclonedds-cpp + plotjuggler + plotjuggler-ros ]; }; };