lopsided98 / nix-ros-overlay

ROS overlay for the Nix package manager
Apache License 2.0
209 stars 83 forks source link

Installing ROS2 Humble & Gazebo11 outside NixOS #398

Closed fromtheeast710 closed 6 months ago

fromtheeast710 commented 6 months ago

How do I install ROS2 Humble and Gazebo packages using the provided nix files? I was able to get the turtlebot3 example working but all installed packages disappear after I close my shell which really confuse me and I'm still too new to Nix to figure this out myself.

I'm using Nix in Artix Linux and installed it via the installation script.

fromtheeast710 commented 6 months ago

Wait I think this should work

{
  inputs = {
    nix-ros-overlay.url = "github:lopsided98/nix-ros-overlay";
    nixpkgs.follows = "nix-ros-overlay/nixpkgs";  # IMPORTANT!!!
  };
  outputs = { self, nix-ros-overlay, nixpkgs }:
    nix-ros-overlay.inputs.flake-utils.lib.eachDefaultSystem (system:
      let
        pkgs = import nixpkgs {
          inherit system;
          overlays = [ nix-ros-overlay.overlays.default ];
        };
      in {
        devShells.default = pkgs.mkShell {
          name = "Example project";
          packages = with pkgs.rosPackages.humble; [
            pkgs.gazebo # install the gazebo package
            pkgs.colcon
            ros-core
          ];
        };
      });
  nixConfig = {
    extra-substituters = [ "https://ros.cachix.org" ];
    extra-trusted-public-keys = [ "ros.cachix.org-1:dSyZxI8geDCJrwgvCOHDoAfOm5sV1wCPjBkKL+38Rvo=" ];
  };
}

Packages still disappear though, do I need to execute nix develop every time?