Conversation
There was a problem hiding this comment.
Pull request overview
Adds a Nix flake to provide a reproducible Rust + ROS 2 (Jazzy) development shell for this workspace, with pinned inputs via flake.lock.
Changes:
- Introduces
flake.nixdefining adevShellwith Rust toolchain, ROS 2 Jazzy packages, and environment setup hooks. - Adds
flake.lockto pinnixpkgs,nix-ros-overlay,rust-overlay, andflake-utilsfor repeatable environments.
Reviewed changes
Copilot reviewed 1 out of 2 changed files in this pull request and generated 7 comments.
| File | Description |
|---|---|
| flake.nix | Defines the Nix flake dev shell, ROS package environment, and shell hooks for building rclrs against ROS 2 Jazzy. |
| flake.lock | Pins flake inputs to specific revisions/hashes for reproducible builds. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
flake.nix
Outdated
| #!/usr/bin/env sh | ||
| SETUPEOF | ||
| cat > "$synthetic_prefix/local_setup.bash" <<'SETUPEOF' | ||
| #!/usr/bin/env bash | ||
| SETUPEOF | ||
| cat > "$synthetic_prefix/local_setup.zsh" <<'SETUPEOF' | ||
| #!/usr/bin/env zsh |
There was a problem hiding this comment.
The heredoc body that writes local_setup.* is indented, so the #! line won’t start at byte 1 of the file. If these scripts are executed directly, they may fail with an exec format error. Write the heredoc contents without leading indentation so the shebang is valid.
| #!/usr/bin/env sh | |
| SETUPEOF | |
| cat > "$synthetic_prefix/local_setup.bash" <<'SETUPEOF' | |
| #!/usr/bin/env bash | |
| SETUPEOF | |
| cat > "$synthetic_prefix/local_setup.zsh" <<'SETUPEOF' | |
| #!/usr/bin/env zsh | |
| #!/usr/bin/env sh | |
| SETUPEOF | |
| cat > "$synthetic_prefix/local_setup.bash" <<'SETUPEOF' | |
| #!/usr/bin/env bash | |
| SETUPEOF | |
| cat > "$synthetic_prefix/local_setup.zsh" <<'SETUPEOF' | |
| #!/usr/bin/env zsh |
flake.nix
Outdated
|
|
||
| synthetic_prefix="$PWD/.nix-ament-prefix" |
There was a problem hiding this comment.
synthetic_prefix is created under $PWD (.nix-ament-prefix), which will modify the working tree and can leave untracked files in the repo. Consider placing this under a cache/temp location (e.g., $XDG_CACHE_HOME or $TMPDIR) to avoid polluting the workspace.
| synthetic_prefix="$PWD/.nix-ament-prefix" | |
| local base_dir | |
| if [ -n "${XDG_CACHE_HOME:-}" ]; then | |
| base_dir="$XDG_CACHE_HOME" | |
| elif [ -n "${TMPDIR:-}" ]; then | |
| base_dir="$TMPDIR" | |
| else | |
| base_dir="/tmp" | |
| fi | |
| synthetic_prefix="$base_dir/nix-ament-prefix" |
flake.nix
Outdated
| description = "ros flake"; | ||
|
|
||
| inputs = { | ||
| nix-ros-overlay.url = "github:lopsided98/nix-ros-overlay/master"; |
There was a problem hiding this comment.
The input URL github:lopsided98/nix-ros-overlay/master bakes the branch name into the flake. Since flake.lock already pins the exact revision, consider using github:lopsided98/nix-ros-overlay (or an explicit tag/rev) to avoid breakage if the default branch name changes.
| nix-ros-overlay.url = "github:lopsided98/nix-ros-overlay/master"; | |
| nix-ros-overlay.url = "github:lopsided98/nix-ros-overlay"; |
flake.nix
Outdated
|
|
||
| outputs = | ||
| { self, nixpkgs, rust-overlay, flake-utils, nix-ros-overlay, ... }: | ||
| flake-utils.lib.eachDefaultSystem ( |
There was a problem hiding this comment.
flake-utils.lib.eachDefaultSystem will create outputs for macOS as well as Linux. Since the devShell is ROS 2–based (and most ROS Nix overlays are Linux-only), consider restricting to Linux systems explicitly (e.g., eachSystem [ "x86_64-linux" "aarch64-linux" ]) to avoid flake evaluation failures on unsupported platforms.
| flake-utils.lib.eachDefaultSystem ( | |
| flake-utils.lib.eachSystem [ "x86_64-linux" "aarch64-linux" ] ( |
There was a problem hiding this comment.
Should this be narrowed down to Linux and some specific architectures?
There was a problem hiding this comment.
Yes. In eb61925 I narrowed the flake outputs to Linux only: x86_64-linux and aarch64-linux.
flake.nix
Outdated
| export CC=clang | ||
| export CXX=clang++ | ||
| export CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_LINKER=clang |
There was a problem hiding this comment.
CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_LINKER is hard-coded to the x86_64 target triple. This will be incorrect on aarch64-linux (and any non-x86_64 system) and can cause Cargo to ignore the intended linker or fail builds. Consider either removing this override or setting the linker env var based on the current target triple.
flake.nix
Outdated
| ]; | ||
|
|
||
| RUST_SRC_PATH = "${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}"; |
There was a problem hiding this comment.
RUST_SRC_PATH is taken from pkgs.rust.packages.stable..., but this dev shell installs Rust via pkgs.rust-bin.stable.latest.... This can point to a different toolchain (or a missing src path) and break tools that rely on RUST_SRC_PATH. Prefer deriving RUST_SRC_PATH from the same rust-bin toolchain included in packages.
flake.nix
Outdated
|
|
||
| pkgs = import nixpkgs { | ||
| inherit system overlays; | ||
| config.allowUnfree = true; |
There was a problem hiding this comment.
config.allowUnfree = true; enables unfree packages globally for this flake evaluation. If the dev shell doesn’t actually require unfree software, consider removing this or making it conditional to avoid surprising users/orgs with strict unfree policies.
| config.allowUnfree = true; | |
| config.allowUnfree = builtins.getEnv "ALLOW_UNFREE" == "1"; |
| pkgs.colcon | ||
| (with rosDistro; buildEnv { | ||
| paths = [ | ||
| ros-core |
There was a problem hiding this comment.
I'd reduce the list of packages to ros-core and ros-base, adding moveit and ackermann-msgs seems out of scope.
There was a problem hiding this comment.
ups, yeah, that's just a copy form another project :/
There was a problem hiding this comment.
Reduced the package set in eb61925 to the narrower ROS environment and removed the out-of-scope extras. The shell now builds around ros-core, ros-base, cyclonedds, rmw-cyclonedds-cpp, and test-msgs.
flake.nix
Outdated
|
|
||
| pkgs = import nixpkgs { | ||
| inherit system overlays; | ||
| config.allowUnfree = true; |
There was a problem hiding this comment.
No need to allow unfree packages.
There was a problem hiding this comment.
Removed allowUnfree in eb61925.
flake.nix
Outdated
|
|
||
| outputs = | ||
| { self, nixpkgs, rust-overlay, flake-utils, nix-ros-overlay, ... }: | ||
| flake-utils.lib.eachDefaultSystem ( |
There was a problem hiding this comment.
Should this be narrowed down to Linux and some specific architectures?
|
@esteve all your comments are valid. ahah, sorry, i thought i removed all unnecessary things when copied from another project. Will update it this weekend with those changes :) |
|
All addressed before the weekend could even arrive. :) |
Summary
Notes
Verification