diff --git a/README.md b/README.md index d2c1ec5bd4..47aeb1d886 100644 --- a/README.md +++ b/README.md @@ -39,6 +39,9 @@ nix develop github:lopsided98/nix-ros-overlay#example-turtlebot3-gazebo Using the overlay in your `flake.nix`-based project could look like this: + + + ```nix { inputs = { @@ -59,10 +62,10 @@ Using the overlay in your `flake.nix`-based project could look like this: pkgs.colcon # ... other non-ROS packages (with pkgs.rosPackages.humble; buildEnv { - paths = [ - ros-core - # ... other ROS packages - ]; + paths = [ + ros-core + # ... other ROS packages + ]; }) ]; }; @@ -73,6 +76,9 @@ Using the overlay in your `flake.nix`-based project could look like this: }; } ``` +You can use the following command to use the above template easily: + + nix flake init --template github:lopsided98/nix-ros-overlay [flake]: https://wiki.nixos.org/wiki/Flakes diff --git a/examples/flake/flake.nix b/examples/flake/flake.nix new file mode 100644 index 0000000000..af8a33b3b8 --- /dev/null +++ b/examples/flake/flake.nix @@ -0,0 +1,32 @@ +{ + inputs = { + nix-ros-overlay.url = "github:lopsided98/nix-ros-overlay/master"; + 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 = [ + pkgs.colcon + # ... other non-ROS packages + (with pkgs.rosPackages.humble; buildEnv { + paths = [ + ros-core + # ... other ROS packages + ]; + }) + ]; + }; + }); + nixConfig = { + extra-substituters = [ "https://ros.cachix.org" ]; + extra-trusted-public-keys = [ "ros.cachix.org-1:dSyZxI8geDCJrwgvCOHDoAfOm5sV1wCPjBkKL+38Rvo=" ]; + }; +} diff --git a/flake.nix b/flake.nix index fe578fc02c..1cd2266f4e 100644 --- a/flake.nix +++ b/flake.nix @@ -32,6 +32,10 @@ nixosModule = nixpkgs.lib.warn "'nix-ros-overlay.nixosModule' is deprecated, use 'nix-ros-overlay.nixosModules.default' instead" self.nixosModules.default; + templates.default = { + path = ./examples/flake; + description = "Basic ROS flake"; + }; }; nixConfig = {