{"id":18655097,"url":"https://github.com/hacker1024/nix-ros-workspace","last_synced_at":"2025-07-25T11:14:41.623Z","repository":{"id":184645309,"uuid":"672234526","full_name":"hacker1024/nix-ros-workspace","owner":"hacker1024","description":"An opinionated builder for ROS workspaces using lopsided98/nix-ros-overlay.","archived":false,"fork":false,"pushed_at":"2025-06-04T01:42:26.000Z","size":49,"stargazers_count":23,"open_issues_count":0,"forks_count":5,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-07-13T15:46:02.350Z","etag":null,"topics":["colcon","nix","nix-ros-overlay","ros","ros2"],"latest_commit_sha":null,"homepage":"","language":"Nix","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hacker1024.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-07-29T11:27:12.000Z","updated_at":"2025-06-18T11:12:17.000Z","dependencies_parsed_at":"2023-12-04T06:24:13.561Z","dependency_job_id":"98c8d222-0b87-4763-b136-a3fe8aadb079","html_url":"https://github.com/hacker1024/nix-ros-workspace","commit_stats":null,"previous_names":["hacker1024/nix-ros-workspace"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/hacker1024/nix-ros-workspace","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hacker1024%2Fnix-ros-workspace","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hacker1024%2Fnix-ros-workspace/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hacker1024%2Fnix-ros-workspace/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hacker1024%2Fnix-ros-workspace/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hacker1024","download_url":"https://codeload.github.com/hacker1024/nix-ros-workspace/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hacker1024%2Fnix-ros-workspace/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266997208,"owners_count":24018935,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-25T02:00:09.625Z","response_time":70,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["colcon","nix","nix-ros-overlay","ros","ros2"],"created_at":"2024-11-07T07:17:48.067Z","updated_at":"2025-07-25T11:14:41.570Z","avatar_url":"https://github.com/hacker1024.png","language":"Nix","funding_links":[],"categories":[],"sub_categories":[],"readme":"# nix-ros-workspace\n\nAn opinionated builder for ROS workspaces using [lopsided98/nix-ros-overlay].\n\n## Quickstart\n\nTo open a shell with ROS 2: Humble Hawksbill, `rviz2`, and `turtlesim`:\n\n```console\n$ nix-shell \\\n  --extra-substituters 'https://ros.cachix.org' --extra-trusted-public-keys 'ros.cachix.org-1:dSyZxI8geDCJrwgvCOHDoAfOm5sV1wCPjBkKL+38Rvo=' \\\n  https://github.com/hacker1024/nix-ros-workspace/archive/master.tar.gz -A cli.env \\\n  --argstr distro humble \\\n  --argstr rosPackages 'rviz2 turtlesim'\n```\n\nOr, to build a derivation containing all of the above, use `nix-build` and remove the `.env`:\n\n```console\n$ nix-build \\\n  --extra-substituters 'https://ros.cachix.org' --extra-trusted-public-keys 'ros.cachix.org-1:dSyZxI8geDCJrwgvCOHDoAfOm5sV1wCPjBkKL+38Rvo=' \\\n  https://github.com/hacker1024/nix-ros-workspace/archive/master.tar.gz -A cli \\\n  --argstr distro humble \\\n  --argstr rosPackages 'rviz2 turtlesim'\n```\n\n## Rationale\n\n[lopsided98/nix-ros-overlay] provides a variant of `buildEnv` that allows ROS\npackages to see each other. This falls short in a few ways, though:\n\n- ROS 2 is not well supported.\n- Non-ROS packages added to the environment do not get included outside of `nix-shell`.\n- There is no clear way to set up a development environment with a mix of\n  prebuilt packages and package build inputs.\n\nThe `buildROSWorkspace` function included in this repository aims to solve these\nissues.\n\n## Setup\n\n1. Set up [lopsided98/nix-ros-overlay], ensuring that [PR #269](https://github.com/lopsided98/nix-ros-overlay/pull/269) is included.\n2. Add the overlay from this repository (`(import /path/to/repository { }).overlay`).\n\n## Usage\n\n### API\n\n`buildROSWorkspace` is included in the ROS distro package sets. The following\nexamples are designed to be invoked with [`callPackage`](https://nixos.org/guides/nix-pills/callpackage-design-pattern.html), e.g.\n`rosPackages.rolling.callPackage`.\n\n`buildROSWorkspace` takes a derivation name and several sets of packages.\n\n- `devPackages` are packages that are under active development. They will be\navailable in the release environment (`nix-build`), but in the development\nenvironment (`nix-shell`), only the build inputs of the packages will be\navailable.\n\n- `prebuiltPackages` are packages that are not under active development (typically\nthird-party packages). They will be available in both the release and\ndevelopment environments.\n\n- `prebuiltShellPackages` are packages that will get added only to the development\nshell environment. This is useful for build tools like GDB.\n\nIn order to set a default ROS domain ID, the `manualDomainId` argument can be\nset. This defaults to the value of the `NRWS_DOMAIN_ID` environment variable at\nevaluation time, or `0` if it is unset.\n\n```nix\n{ buildROSWorkspace\n, rviz2\n, my-package-1\n, my-package-2\n}:\n\nbuildROSWorkspace {\n  name = \"my\";\n  devPackages = {\n    inherit\n      my-package-1\n      my-package-2;\n  };\n  prebuiltPackages = {\n    inherit\n      rviz2;\n  };\n}\n```\n\n#### Sibling dependencies\n\nSome packages expect other packages to be available in the workspace, without\ndepending on them directly. Many launch files, for example, attempt to run\narbitrary nodes and programs.\n\nTo accomodate this, the `workspacePackages` passthru attribute is available.\nPackages added to this set will be detected by `buildROSWorkspace` and added to\n`prebuiltPackages`, along with any `workspacePackages` of their own.\n\n```nix\n{ buildRosPackage\n, xacro\n, gazebo-ros\n}:\n\nbuildRosPackage {\n  # ...\n  passthru.workspacePackages = {\n    inherit\n      xacro\n      gazebo-ros;\n  };\n}\n```\n\n### Command line\n\nThe following examples assume a `default.nix` exists, evaluating to the result\nof a `buildROSWorkspace` call.\n\n#### Building\n\nTo build a workspace as a regular Nix package:\n\n```\n$ nix-build\n\n$ # Then, for example:\n$ ./result/bin/ros2 pkg list\n```\n\nTo enter a shell in the workspace release environment:\n\n```\n$ nix-shell -p 'import ./. { }'\n$ eval \"$(mk-workspace-shell-setup)\"\n\n$ # Then, for example:\n$ ros2 pkg list\n```\n\n#### Developing\n\nTo enter a shell in the workspace development environment:\n\n```\n$ nix-shell -A env\n\n$ # Then, for example:\n$ cd ~/ros_ws\n$ colcon build\n```\n\n##### Composition\n\n###### For\n\n`env` also includes a \"sub-environment\" for each package in `devPackages`. These\nenvironments are identical to the main environment, but all packages other than\nthe specified one are moved into `prebuiltPackages`.\n\nIn the example below, `my-package-1`'s build dependencies will be available as\nnormal, but `my-package-2` will be available as if it were in `prebuiltPackages`.\n\n```\n$ nix-shell -A env.for.my-package-1\n```\n\n###### And\n\nOften, it is useful to work with a subset of the `devPackages`. This can be done by\nusing the `and` attributes, which move the selected `prebuiltPackages` back into the\n`devPackages`.\n\nFor example, to work with both `my-package-1` and `my-package-2` as `devPackages`:\n\n```\n$ nix-shell -A env.for.my-package-1.and.my-package-2\n```\n\nThe `.for.my-package-1` moves all but `my-package-1` into `prebuiltPackages`, and the\n`.and.my-package-2` brings `my-package-2` back.\n\nThese techniques are preferable to `nix-shell -A my-package-1`, as the former will include\nstandard workspace tools and ROS 2 fixes.\n\n[lopsided98/nix-ros-overlay]: https://github.com/lopsided98/nix-ros-overlay\n\n###### Shortcuts\n\n`for` and `and` can be left out. These two values are the same:\n\n```\nenv.for.my-package-1.and.my-package-2\n```\n\n```\nenv.my-package-1.my-package-2\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhacker1024%2Fnix-ros-workspace","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhacker1024%2Fnix-ros-workspace","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhacker1024%2Fnix-ros-workspace/lists"}