diff --git a/.github/actions/nix-ros-build-action/eval.nix b/.github/actions/nix-ros-build-action/eval.nix index 11b0ecee22..c6e643209a 100644 --- a/.github/actions/nix-ros-build-action/eval.nix +++ b/.github/actions/nix-ros-build-action/eval.nix @@ -1,22 +1,37 @@ # Evaluate `release.nix' like Hydra would. Too bad nix-instantiate can't to do this. -{ lib ? pkgs.lib, pkgs }: +{ + lib ? pkgs.lib, + pkgs, +}: let trace = if builtins.getEnv "VERBOSE" == "1" then builtins.trace else (x: y: y); # Add the ‘recurseForDerivations’ attribute to ensure that # nix-instantiate recurses into nested attribute sets. - recurse = path: attrs: + recurse = + path: attrs: if (builtins.tryEval attrs).success then - if lib.isDerivation attrs - then - if (builtins.tryEval attrs.drvPath).success - then { inherit (attrs) name drvPath; } - else { failed = true; } + if lib.isDerivation attrs then + if (builtins.tryEval attrs.drvPath).success then + { inherit (attrs) name drvPath; } + else + { failed = true; } else if lib.isAttrs attrs && (attrs.recurseForDerivations or false) then - { recurseForDerivations = true; } // - lib.mapAttrs (n: v: let path' = path ++ [n]; in trace path' (recurse path' v)) attrs - else { } - else { }; + { + recurseForDerivations = true; + } + // lib.mapAttrs ( + n: v: + let + path' = path ++ [ n ]; + in + trace path' (recurse path' v) + ) attrs + else + { } + else + { }; -in recurse [] pkgs +in +recurse [ ] pkgs diff --git a/.github/actions/nix-ros-build-action/shell.nix b/.github/actions/nix-ros-build-action/shell.nix index 3a7a1b7c8a..4296df1d06 100644 --- a/.github/actions/nix-ros-build-action/shell.nix +++ b/.github/actions/nix-ros-build-action/shell.nix @@ -1,4 +1,8 @@ -{ mkShell, nodejs, cachix }: +{ + mkShell, + nodejs, + cachix, +}: mkShell { name = "nix-ros-build-action-shell"; diff --git a/.github/workflows/check-nix-fmt.yaml b/.github/workflows/check-nix-fmt.yaml new file mode 100644 index 0000000000..b5ecebb07c --- /dev/null +++ b/.github/workflows/check-nix-fmt.yaml @@ -0,0 +1,66 @@ +# This file was mostly copied from nixpkgs's check-nix-format.yml, +# which itself wsa mostly copied from nixpkgs's check-maintainers-sorted.yaml. + +name: Check that Nix files are formatted + +on: + pull_request: + types: [opened, synchronize, reopened] +permissions: + contents: read + +jobs: + nixos: + name: nixfmt-check + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 2 + - name: Calculate changed files + id: changed-files + run: echo "changed_files=$(git diff --name-only -r HEAD^1 HEAD | xargs)" >> $GITHUB_OUTPUT + - uses: cachix/install-nix-action@v30 + with: + extra_nix_config: sandbox = true + nix_path: nixpkgs=channel:nixpkgs-unstable + - name: Install nixfmt + run: "nix-env -f '' -iAP nixfmt-rfc-style" + - name: Check that Nix files are formatted according to the RFC style + run: | + # List of changed files + changed_files="${{ steps.changed-files.outputs.changed_files }}" + + # Convert the string of changed files into an array + IFS=' ' read -r -a files <<< "$changed_files" + + # A variable to track failures + failure=0 + + # Function to check the file and run nixfmt + check_file() { + local file="$1" + if [[ -f "$file" ]]; then + if ! nixfmt --check "$file"; then + echo "::error file=$file::Formatting check failed for $file" >&2 + failure=1 + fi + else + echo "File does not exist: $file" >&2 + fi + } + + # Export the function and failure variable for parallel execution + export -f check_file + export failure + + # Remove distros folder (not nixfmt-ed) + rm -rf distros + + # Run the checks in parallel + printf "%s\n" "${files[@]}" | xargs -n 1 -P "$(nproc)" -I {} bash -c 'check_file "$@"' _ {} + + # Exit with a status of 1 if any checks failed + if [[ $failure -eq 1 ]]; then + exit 1 + fi diff --git a/default.nix b/default.nix index c8be439d85..10fcddbd50 100644 --- a/default.nix +++ b/default.nix @@ -5,10 +5,15 @@ let sha256 = lock.nodes.nixpkgs.locked.narHash; }; in -{ nixpkgs ? lockedNixpkgs -, overlays ? [] -, ... }@args: +{ + nixpkgs ? lockedNixpkgs, + overlays ? [ ], + ... +}@args: -import nixpkgs (args // { - overlays = [ (import ./overlay.nix) ] ++ overlays; -}) +import nixpkgs ( + args + // { + overlays = [ (import ./overlay.nix) ] ++ overlays; + } +) diff --git a/examples/flake/flake.nix b/examples/flake/flake.nix index af8a33b3b8..e22508a8ca 100644 --- a/examples/flake/flake.nix +++ b/examples/flake/flake.nix @@ -1,30 +1,41 @@ { inputs = { nix-ros-overlay.url = "github:lopsided98/nix-ros-overlay/master"; - nixpkgs.follows = "nix-ros-overlay/nixpkgs"; # IMPORTANT!!! + nixpkgs.follows = "nix-ros-overlay/nixpkgs"; # IMPORTANT!!! }; - outputs = { self, nix-ros-overlay, nixpkgs }: - nix-ros-overlay.inputs.flake-utils.lib.eachDefaultSystem (system: + 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 { + 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 - ]; - }) + ( + 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/examples/ros2-basic.nix b/examples/ros2-basic.nix index a5ab46a1bf..5a37439a7d 100755 --- a/examples/ros2-basic.nix +++ b/examples/ros2-basic.nix @@ -1,6 +1,8 @@ # Environment containing basic ROS2 tools -{ pkgs ? import ../. {} }: +{ + pkgs ? import ../. { }, +}: with pkgs; with rosPackages.humble; diff --git a/examples/ros2-gz.nix b/examples/ros2-gz.nix index a3046070f3..e45c8bf9bc 100644 --- a/examples/ros2-gz.nix +++ b/examples/ros2-gz.nix @@ -2,42 +2,44 @@ # to run this dev shell use: # NIXPKGS_ALLOW_INSECURE=1 nix develop --impure .\#example-ros2-gz -{pkgs ? import ../. {}}: +{ + pkgs ? import ../. { }, +}: with pkgs; with rosPackages.jazzy; - mkShell { - nativeBuildInputs = [ - (buildEnv { - paths = [ - colcon - ros-core - ament-cmake-core - python-cmake-module - # ros-gz +mkShell { + nativeBuildInputs = [ + (buildEnv { + paths = [ + colcon + ros-core + ament-cmake-core + python-cmake-module + # ros-gz - gz-cmake-vendor - gz-common-vendor - gz-dartsim-vendor - gz-fuel-tools-vendor - gz-gui-vendor - gz-launch-vendor - gz-math-vendor - gz-msgs-vendor - gz-ogre-next-vendor - gz-physics-vendor - gz-plugin-vendor - gz-rendering-vendor - gz-sensors-vendor - gz-sim-vendor - gz-tools-vendor - gz-transport-vendor - gz-utils-vendor - ]; - }) - ]; - # Gazebo is currently broken on Wayland - # https://gazebosim.org/docs/ionic/troubleshooting/#wayland-issues - shellHook = '' - unset QT_QPA_PLATFORM - ''; - } + gz-cmake-vendor + gz-common-vendor + gz-dartsim-vendor + gz-fuel-tools-vendor + gz-gui-vendor + gz-launch-vendor + gz-math-vendor + gz-msgs-vendor + gz-ogre-next-vendor + gz-physics-vendor + gz-plugin-vendor + gz-rendering-vendor + gz-sensors-vendor + gz-sim-vendor + gz-tools-vendor + gz-transport-vendor + gz-utils-vendor + ]; + }) + ]; + # Gazebo is currently broken on Wayland + # https://gazebosim.org/docs/ionic/troubleshooting/#wayland-issues + shellHook = '' + unset QT_QPA_PLATFORM + ''; +} diff --git a/examples/turtlebot3-gazebo.nix b/examples/turtlebot3-gazebo.nix index 49c30f1511..179fbc54c5 100755 --- a/examples/turtlebot3-gazebo.nix +++ b/examples/turtlebot3-gazebo.nix @@ -2,7 +2,9 @@ # roslaunch turtlebot3_gazebo turtlebot3_world.launch # roslaunch turtlebot3_teleop turtlebot3_teleop_key.launch -{ pkgs ? import ../. {} }: +{ + pkgs ? import ../. { }, +}: with pkgs; with rosPackages.noetic; with pythonPackages; @@ -10,14 +12,16 @@ with pythonPackages; mkShell { buildInputs = [ glibcLocales - (buildEnv { paths = [ - rosbash - turtlebot3-description - turtlebot3-teleop - turtlebot3-gazebo - gazebo-plugins - xacro - ]; }) + (buildEnv { + paths = [ + rosbash + turtlebot3-description + turtlebot3-teleop + turtlebot3-gazebo + gazebo-plugins + xacro + ]; + }) ]; ROS_HOSTNAME = "localhost"; diff --git a/flake.nix b/flake.nix index bb8549f09a..b52420bd53 100644 --- a/flake.nix +++ b/flake.nix @@ -6,35 +6,41 @@ flake-utils.url = "github:numtide/flake-utils"; }; - outputs = { self, nixpkgs, flake-utils }: + outputs = + { + self, + nixpkgs, + flake-utils, + }: with nixpkgs.lib; with flake-utils.lib; - eachSystem systems.flakeExposed (system: let - pkgs = import nixpkgs { - inherit system; - overlays = [ self.overlays.default ]; - }; - in { - legacyPackages = pkgs.rosPackages; + eachSystem systems.flakeExposed ( + system: + let + pkgs = import nixpkgs { + inherit system; + overlays = [ self.overlays.default ]; + }; + in + { + legacyPackages = pkgs.rosPackages; - devShells = { - example-turtlebot3-gazebo = import ./examples/turtlebot3-gazebo.nix { inherit pkgs; }; - example-ros2-basic = import ./examples/ros2-basic.nix { inherit pkgs; }; - example-ros2-gz = import ./examples/ros2-gz.nix { inherit pkgs; }; + devShells = { + example-turtlebot3-gazebo = import ./examples/turtlebot3-gazebo.nix { inherit pkgs; }; + example-ros2-basic = import ./examples/ros2-basic.nix { inherit pkgs; }; + example-ros2-gz = import ./examples/ros2-gz.nix { inherit pkgs; }; - # Development environment for the custom GitHub action - nix-ros-build-action = pkgs.callPackage ./.github/actions/nix-ros-build-action/shell.nix { }; - }; - }) // { + # Development environment for the custom GitHub action + nix-ros-build-action = pkgs.callPackage ./.github/actions/nix-ros-build-action/shell.nix { }; + }; + } + ) + // { overlays.default = import ./overlay.nix; nixosModules.default = ./modules; - overlay = nixpkgs.lib.warn - "'nix-ros-overlay.overlay' is deprecated, use 'nix-ros-overlay.overlays.default' instead" - self.overlays.default; - nixosModule = nixpkgs.lib.warn - "'nix-ros-overlay.nixosModule' is deprecated, use 'nix-ros-overlay.nixosModules.default' instead" - self.nixosModules.default; + overlay = nixpkgs.lib.warn "'nix-ros-overlay.overlay' is deprecated, use 'nix-ros-overlay.overlays.default' instead" self.overlays.default; + 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"; diff --git a/lib/default.nix b/lib/default.nix index 7ea84179c5..bc8b9d076c 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -1,159 +1,230 @@ -{ lib ? rosSelf.lib or self.lib -, self ? null -, rosSelf ? null }: { - mkOverlay = overlays: let - s = lib.composeManyExtensions overlays s {}; - in s; + lib ? rosSelf.lib or self.lib, + self ? null, + rosSelf ? null, +}: +{ + mkOverlay = + overlays: + let + s = lib.composeManyExtensions overlays s { }; + in + s; # Create a tarball of a package source. If the source is already an archive, # it will be unpacked and repacked as a tarball. - tarSource = { - compress ? false, - hook ? "", - hash ? null - }: src: self.runCommand ("${src.name}.tar" + lib.optionalString compress ".gz") ({ - inherit src; - } // lib.optionalAttrs (hash != null) { - outputHashMode = "flat"; - outputHash = hash; - }) '' - unpackPhase - pushd "$sourceRoot" - ${hook} - popd - tar --sort=name \ - --format=gnu \ - --owner=0 --group=0 --numeric-owner \ - --mtime="@$SOURCE_DATE_EPOCH" \ - ${lib.optionalString compress "-z"} \ - -cf "$out" "$sourceRoot" - ''; - - patchVendorUrl = pkg: { - url, hash ? "", sha256 ? "", - originalUrl ? url, - file ? "CMakeLists.txt" - }: pkg.overrideAttrs ({ - postPatch ? "", ... - }: { - postPatch = '' - substituteInPlace ${lib.escapeShellArg file} \ - --replace-fail ${lib.escapeShellArg originalUrl} ${lib.escapeShellArg (self.fetchurl { inherit url hash sha256; })} - '' + postPatch; - }); - - patchExternalProjectGit = pkg: { - url, - rev, - originalRev ? rev, - originalUrl ? url, - revVariable ? "", - file ? "CMakeLists.txt", - fetchgitArgs ? {} - }: pkg.overrideAttrs ({ - postPatch ? "", ... - }: { - postPatch = let - script = '' - $0 ~ "GIT_REPOSITORY[[:blank:]]+" originalUrl \ - { print "URL \"" path "\""; foundUrl=1; next } \ - { print } - $0 ~ "GIT_TAG[[:blank:]]+" originalRev { print; foundRev=1 } - $0 ~ "set\\(" revVariable "[[:blank:]]+\"?" originalRev "\"?\\)" { print; foundRev=1 } - END { - if (!foundUrl) print "patchExternalProjectGit: did not find URL: " originalUrl > "/dev/stderr" - if (!foundRev) print "patchExternalProjectGit: did not find revision: " originalRev > "/dev/stderr" - exit !(foundUrl && foundRev) + tarSource = + { + compress ? false, + hook ? "", + hash ? null, + }: + src: + self.runCommand ("${src.name}.tar" + lib.optionalString compress ".gz") + ( + { + inherit src; } + // lib.optionalAttrs (hash != null) { + outputHashMode = "flat"; + outputHash = hash; + } + ) + '' + unpackPhase + pushd "$sourceRoot" + ${hook} + popd + tar --sort=name \ + --format=gnu \ + --owner=0 --group=0 --numeric-owner \ + --mtime="@$SOURCE_DATE_EPOCH" \ + ${lib.optionalString compress "-z"} \ + -cf "$out" "$sourceRoot" ''; - in '' - awk -i inplace \ - -v originalUrl=${lib.escapeShellArg originalUrl} \ - -v originalRev=${lib.escapeShellArg originalRev} \ - -v revVariable=${lib.escapeShellArg revVariable} \ - -v path=${lib.escapeShellArg (self.fetchgit ({ inherit url rev; } // fetchgitArgs))} \ - ${lib.escapeShellArg script} \ - ${lib.escapeShellArg file} - '' + postPatch; - }); + + patchVendorUrl = + pkg: + { + url, + hash ? "", + sha256 ? "", + originalUrl ? url, + file ? "CMakeLists.txt", + }: + pkg.overrideAttrs ( + { + postPatch ? "", + ... + }: + { + postPatch = + '' + substituteInPlace ${lib.escapeShellArg file} \ + --replace-fail ${lib.escapeShellArg originalUrl} ${ + lib.escapeShellArg (self.fetchurl { inherit url hash sha256; }) + } + '' + + postPatch; + } + ); + + patchExternalProjectGit = + pkg: + { + url, + rev, + originalRev ? rev, + originalUrl ? url, + revVariable ? "", + file ? "CMakeLists.txt", + fetchgitArgs ? { }, + }: + pkg.overrideAttrs ( + { + postPatch ? "", + ... + }: + { + postPatch = + let + script = '' + $0 ~ "GIT_REPOSITORY[[:blank:]]+" originalUrl \ + { print "URL \"" path "\""; foundUrl=1; next } \ + { print } + $0 ~ "GIT_TAG[[:blank:]]+" originalRev { print; foundRev=1 } + $0 ~ "set\\(" revVariable "[[:blank:]]+\"?" originalRev "\"?\\)" { print; foundRev=1 } + END { + if (!foundUrl) print "patchExternalProjectGit: did not find URL: " originalUrl > "/dev/stderr" + if (!foundRev) print "patchExternalProjectGit: did not find revision: " originalRev > "/dev/stderr" + exit !(foundUrl && foundRev) + } + ''; + in + '' + awk -i inplace \ + -v originalUrl=${lib.escapeShellArg originalUrl} \ + -v originalRev=${lib.escapeShellArg originalRev} \ + -v revVariable=${lib.escapeShellArg revVariable} \ + -v path=${lib.escapeShellArg (self.fetchgit ({ inherit url rev; } // fetchgitArgs))} \ + ${lib.escapeShellArg script} \ + ${lib.escapeShellArg file} + '' + + postPatch; + } + ); # Patch a vendored download that uses ament_vendor() with a Git repo as the # source. - patchAmentVendorGit = pkg: { - url, - originalUrl ? url, - rev, # Must correspond to the VCS_VERSION argument - file ? "CMakeLists.txt", - fetchgitArgs ? {}, - tarSourceArgs ? {} - }: pkg.overrideAttrs ({ - nativeBuildInputs ? [], - postPatch ? "", ... - }: let - # ament_vendor doesn't allow patches for path inputs, so we have to pack it - # into a tar first. Additionally, vcstool only accepts tarballs with the - # version number as the root directory name. - vendor = lib.tarSource tarSourceArgs (self.fetchgit (fetchgitArgs // { - name = rev; - inherit url rev; - })); - in { - # CMake ExternalProject patches are applied with git apply - nativeBuildInputs = nativeBuildInputs ++ [ self.git ]; - postPatch = '' - sed -i '\|VCS_URL\s*${originalUrl}|c\ - VCS_URL "file://${vendor}"\ - VCS_TYPE tar' \ - ${lib.escapeShellArg file} - '' + postPatch; - }); + patchAmentVendorGit = + pkg: + { + url, + originalUrl ? url, + rev, # Must correspond to the VCS_VERSION argument + file ? "CMakeLists.txt", + fetchgitArgs ? { }, + tarSourceArgs ? { }, + }: + pkg.overrideAttrs ( + { + nativeBuildInputs ? [ ], + postPatch ? "", + ... + }: + let + # ament_vendor doesn't allow patches for path inputs, so we have to pack it + # into a tar first. Additionally, vcstool only accepts tarballs with the + # version number as the root directory name. + vendor = lib.tarSource tarSourceArgs ( + self.fetchgit ( + fetchgitArgs + // { + name = rev; + inherit url rev; + } + ) + ); + in + { + # CMake ExternalProject patches are applied with git apply + nativeBuildInputs = nativeBuildInputs ++ [ self.git ]; + postPatch = + '' + sed -i '\|VCS_URL\s*${originalUrl}|c\ + VCS_URL "file://${vendor}"\ + VCS_TYPE tar' \ + ${lib.escapeShellArg file} + '' + + postPatch; + } + ); # patchAmentVendorGit specialized for gz-*-vendor packages. In # addition to patching ament_vendor() calls, it adds a check to # CMakeLists.txt to detect upstream updates of the vendored package # version. - patchGzAmentVendorGit = pkg: { - version, - hash, - tarSourceArgs ? {} - }: let - stem = lib.strings.removeSuffix "-vendor" - (lib.strings.removePrefix "ros-${pkg.rosDistro}-" pkg.pname); # e.g. gz-cmake - majorNum = lib.versions.major version; - patchedPkg = lib.patchAmentVendorGit pkg { - url = "https://github.com/gazebosim/${stem}.git"; - originalUrl = "https://github.com/gazebosim/\${GITHUB_NAME}.git"; - rev = "${stem}${majorNum}_${version}"; # e.g. "gz-cmake3_3.5.3" - fetchgitArgs.hash = hash; - inherit tarSourceArgs; - }; - in patchedPkg.overrideAttrs ({ - pname, postPatch ? "", ... - }: { - postPatch = postPatch + '' - # Use standard installation paths rather than /opt - substituteInPlace CMakeLists.txt \ - --replace-fail 'opt/''${PROJECT_NAME}/extra_cmake' 'share/extra_cmake' - substituteInPlace *-extras.cmake.in \ - --replace-fail 'opt/@PROJECT_NAME@/extra_cmake' 'share/extra_cmake' + patchGzAmentVendorGit = + pkg: + { + version, + hash, + tarSourceArgs ? { }, + }: + let + stem = lib.strings.removeSuffix "-vendor" ( + lib.strings.removePrefix "ros-${pkg.rosDistro}-" pkg.pname + ); # e.g. gz-cmake + majorNum = lib.versions.major version; + patchedPkg = lib.patchAmentVendorGit pkg { + url = "https://github.com/gazebosim/${stem}.git"; + originalUrl = "https://github.com/gazebosim/\${GITHUB_NAME}.git"; + rev = "${stem}${majorNum}_${version}"; # e.g. "gz-cmake3_3.5.3" + fetchgitArgs.hash = hash; + inherit tarSourceArgs; + }; + in + patchedPkg.overrideAttrs ( + { + pname, + postPatch ? "", + ... + }: + { + postPatch = + postPatch + + '' + # Use standard installation paths rather than /opt + substituteInPlace CMakeLists.txt \ + --replace-fail 'opt/''${PROJECT_NAME}/extra_cmake' 'share/extra_cmake' + substituteInPlace *-extras.cmake.in \ + --replace-fail 'opt/@PROJECT_NAME@/extra_cmake' 'share/extra_cmake' - cat >> CMakeLists.txt <<'EOF' - if(NOT ''${LIB_VER} VERSION_EQUAL "${version}") - message(FATAL_ERROR "Mismatch in ${pname} version (Nix: ${version}, upstream: ''${LIB_VER}). Fix this in overrides.nix.") - endif() - EOF - ''; - }); + cat >> CMakeLists.txt <<'EOF' + if(NOT ''${LIB_VER} VERSION_EQUAL "${version}") + message(FATAL_ERROR "Mismatch in ${pname} version (Nix: ${version}, upstream: ''${LIB_VER}). Fix this in overrides.nix.") + endif() + EOF + ''; + } + ); # Many ROS packages claim to have a dependency on Boost signals when they # really don't or they actually depend on signals2. Boost 1.69 removed # signals causing these packages to fail to build. - patchBoostSignals = pkg: pkg.overrideAttrs ({ - postPatch ? "", ... - }: { - postPatch = '' - sed -i '/find_package(Boost [^)]*/s/signals//g' CMakeLists.txt - '' + postPatch; - }); + patchBoostSignals = + pkg: + pkg.overrideAttrs ( + { + postPatch ? "", + ... + }: + { + postPatch = + '' + sed -i '/find_package(Boost [^)]*/s/signals//g' CMakeLists.txt + '' + + postPatch; + } + ); } diff --git a/modules/common.nix b/modules/common.nix index a4f3bff6ce..60496c7dcf 100644 --- a/modules/common.nix +++ b/modules/common.nix @@ -1,11 +1,17 @@ -{ config, lib, pkgs, ... }: +{ + config, + lib, + pkgs, + ... +}: with lib; let ros1Cfg = config.services.ros; ros2Cfg = config.services.ros2; -in { +in +{ # Interface # Implementation diff --git a/modules/default.nix b/modules/default.nix index 9feb559ed4..59f2d3a193 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -1,4 +1,5 @@ -{ ... }: { +{ ... }: +{ imports = [ ./common.nix ./ros1/core.nix diff --git a/modules/ros1/core.nix b/modules/ros1/core.nix index fe7b2c2bbd..1efdc833a2 100644 --- a/modules/ros1/core.nix +++ b/modules/ros1/core.nix @@ -1,11 +1,17 @@ -{ config, lib, pkgs, ... }: +{ + config, + lib, + pkgs, + ... +}: with lib; let rosCfg = config.services.ros; cfg = rosCfg.core; -in { +in +{ # Interface options.services.ros.core = { @@ -25,12 +31,16 @@ in { description = "ROS core"; serviceConfig = { Type = "exec"; - ExecStart = let - env = with rosCfg.pkgs; buildEnv { - name = "roscore-env"; - paths = [ roslaunch ]; - }; - in "${env}/bin/roscore -p ${toString cfg.port}"; + ExecStart = + let + env = + with rosCfg.pkgs; + buildEnv { + name = "roscore-env"; + paths = [ roslaunch ]; + }; + in + "${env}/bin/roscore -p ${toString cfg.port}"; User = "ros"; Group = "ros"; StateDirectory = "ros"; diff --git a/modules/ros1/nodes.nix b/modules/ros1/nodes.nix index 1859fbf554..9c0ef169e3 100644 --- a/modules/ros1/nodes.nix +++ b/modules/ros1/nodes.nix @@ -1,10 +1,15 @@ -{ config, lib, pkgs, ... }: +{ + config, + lib, + pkgs, + ... +}: with lib; let cfg = config.services.ros; - + commonServiceOptions = { package = mkOption { type = types.str; @@ -33,113 +38,135 @@ let }; }; - commonServiceConfig = { name, config, ... }: { - # Try to convert package name to attribute and add it to the - # environment - paths = let - packageAttr = replaceStrings ["_"] ["-"] config.package; - in optional (hasAttr packageAttr cfg.pkgs) cfg.pkgs."${packageAttr}"; - - env = mkDefault (cfg.pkgs.buildEnv { - name = "ros-node-${name}-env"; - inherit (config) paths; - }); - }; - - serviceGenerator = execStartFn: services: mapAttrs' (name: config: nameValuePair name { - serviceConfig = { - Type = "exec"; - StateDirectory = "ros"; - WorkingDirectory = "/var/lib/ros"; - User = "ros"; - Group = "ros"; - ExecStart = execStartFn config; - }; - wants = [ "roscore.service" ]; - after = [ "roscore.service" ]; - wantedBy = [ "multi-user.target" ]; - environment = { - ROS_HOSTNAME = cfg.hostname; - ROS_MASTER_URI = cfg.masterUri; - ROS_HOME = "/var/lib/ros"; + commonServiceConfig = + { name, config, ... }: + { + # Try to convert package name to attribute and add it to the + # environment + paths = + let + packageAttr = replaceStrings [ "_" ] [ "-" ] config.package; + in + optional (hasAttr packageAttr cfg.pkgs) cfg.pkgs."${packageAttr}"; + + env = mkDefault ( + cfg.pkgs.buildEnv { + name = "ros-node-${name}-env"; + inherit (config) paths; + } + ); }; - }) services; -in { + + serviceGenerator = + execStartFn: services: + mapAttrs' ( + name: config: + nameValuePair name { + serviceConfig = { + Type = "exec"; + StateDirectory = "ros"; + WorkingDirectory = "/var/lib/ros"; + User = "ros"; + Group = "ros"; + ExecStart = execStartFn config; + }; + wants = [ "roscore.service" ]; + after = [ "roscore.service" ]; + wantedBy = [ "multi-user.target" ]; + environment = { + ROS_HOSTNAME = cfg.hostname; + ROS_MASTER_URI = cfg.masterUri; + ROS_HOME = "/var/lib/ros"; + }; + } + ) services; +in +{ # Interface options.services.ros = { nodes = mkOption { - type = types.attrsOf (types.submodule ({ name, config, ... }@args: { - options = commonServiceOptions // { - node = mkOption { - type = types.str; - description = '' - Name of the node to launch. - ''; - }; - - args = mkOption { - type = types.listOf types.str; - default = []; - description = '' - Arguments to pass to the node. - ''; - }; - - params = mkOption { - type = types.attrsOf types.str; - default = {}; - description = '' - Key-value parameters to pass to the node. - ''; - }; - }; - - config = mkMerge [ - (commonServiceConfig args) - { paths = [ cfg.pkgs.rosbash ]; } - ]; - })); - default = {}; + type = types.attrsOf ( + types.submodule ( + { name, config, ... }@args: + { + options = commonServiceOptions // { + node = mkOption { + type = types.str; + description = '' + Name of the node to launch. + ''; + }; + + args = mkOption { + type = types.listOf types.str; + default = [ ]; + description = '' + Arguments to pass to the node. + ''; + }; + + params = mkOption { + type = types.attrsOf types.str; + default = { }; + description = '' + Key-value parameters to pass to the node. + ''; + }; + }; + + config = mkMerge [ + (commonServiceConfig args) + { paths = [ cfg.pkgs.rosbash ]; } + ]; + } + ) + ); + default = { }; description = '' ROS nodes to launch at boot as systemd services. ''; }; launchFiles = mkOption { - type = types.attrsOf (types.submodule ({ name, config, ... }@args: { - options = commonServiceOptions // { - launchFile = mkOption { - type = types.str; - description = '' - Name of the launch file to be passed to roslaunch. - ''; - }; - - args = mkOption { - type = types.attrsOf types.str; - default = {}; - description = '' - Key-value arguments to pass to the launch file (defined in - tags) - ''; - }; - - roslaunchArgs = mkOption { - type = types.listOf types.str; - default = []; - description = '' - Extra command line arguments to pass to roslaunch. - ''; - }; - }; - - config = mkMerge [ - (commonServiceConfig args) - { paths = [ cfg.pkgs.roslaunch ]; } - ]; - })); - default = {}; + type = types.attrsOf ( + types.submodule ( + { name, config, ... }@args: + { + options = commonServiceOptions // { + launchFile = mkOption { + type = types.str; + description = '' + Name of the launch file to be passed to roslaunch. + ''; + }; + + args = mkOption { + type = types.attrsOf types.str; + default = { }; + description = '' + Key-value arguments to pass to the launch file (defined in + tags) + ''; + }; + + roslaunchArgs = mkOption { + type = types.listOf types.str; + default = [ ]; + description = '' + Extra command line arguments to pass to roslaunch. + ''; + }; + }; + + config = mkMerge [ + (commonServiceConfig args) + { paths = [ cfg.pkgs.roslaunch ]; } + ]; + } + ) + ); + default = { }; description = '' ROS launch files to start at boot as systemd services. ''; @@ -150,17 +177,33 @@ in { config = mkIf cfg.enable { systemd.services = mkMerge [ - (serviceGenerator (config: escapeShellArgs ( - [ "${config.env}/bin/rosrun" config.package config.node ] ++ - (mapAttrsToList (n: v: "${n}:=${v}") config.params) ++ - config.args - )) cfg.nodes) - (serviceGenerator (config: escapeShellArgs ( - [ "${config.env}/bin/roslaunch" "--wait" ] ++ - config.roslaunchArgs ++ - [ config.package config.launchFile ] ++ - (mapAttrsToList (n: v: "${n}:=${v}") config.args) - )) cfg.launchFiles) + (serviceGenerator ( + config: + escapeShellArgs ( + [ + "${config.env}/bin/rosrun" + config.package + config.node + ] + ++ (mapAttrsToList (n: v: "${n}:=${v}") config.params) + ++ config.args + ) + ) cfg.nodes) + (serviceGenerator ( + config: + escapeShellArgs ( + [ + "${config.env}/bin/roslaunch" + "--wait" + ] + ++ config.roslaunchArgs + ++ [ + config.package + config.launchFile + ] + ++ (mapAttrsToList (n: v: "${n}:=${v}") config.args) + ) + ) cfg.launchFiles) ]; }; } diff --git a/modules/ros1/ros.nix b/modules/ros1/ros.nix index 0ca3bd4675..ab75d2a1a8 100644 --- a/modules/ros1/ros.nix +++ b/modules/ros1/ros.nix @@ -1,4 +1,9 @@ -{ config, lib, pkgs, ... }: +{ + config, + lib, + pkgs, + ... +}: with lib; @@ -15,7 +20,8 @@ let description = "ROS package set overlay"; check = isFunction; }; -in { +in +{ # Interface options.services.ros = { @@ -38,7 +44,7 @@ in { overlays = mkOption { type = types.listOf overlayType; - default = []; + default = [ ]; apply = composeManyExtensions; description = '' Set of package overlays to apply to ROS package set for the configured @@ -64,7 +70,7 @@ in { }; systemPackages = mkOption { - default = p: []; + default = p: [ ]; example = literalExample "p: with p; [ roslaunch ]"; description = '' Packages to add to a ROS environment that will be added to the system @@ -94,12 +100,16 @@ in { ROS_MASTER_URI = cfg.masterUri; }; - environment.systemPackages = let - paths = cfg.systemPackages cfg.pkgs; - in mkIf (length paths != 0) [ (cfg.pkgs.buildEnv { - name = "ros-system-env"; - inherit paths; - extraOutputsToInstall = optional config.environment.enableDebugInfo "debug"; - }) ]; + environment.systemPackages = + let + paths = cfg.systemPackages cfg.pkgs; + in + mkIf (length paths != 0) [ + (cfg.pkgs.buildEnv { + name = "ros-system-env"; + inherit paths; + extraOutputsToInstall = optional config.environment.enableDebugInfo "debug"; + }) + ]; }; } diff --git a/modules/ros2/nodes.nix b/modules/ros2/nodes.nix index 157bec8b3c..724fae3779 100644 --- a/modules/ros2/nodes.nix +++ b/modules/ros2/nodes.nix @@ -1,10 +1,15 @@ -{ config, lib, pkgs, ... }: +{ + config, + lib, + pkgs, + ... +}: with lib; let cfg = config.services.ros2; - + commonServiceOptions = { package = mkOption { type = types.str; @@ -33,120 +38,147 @@ let }; }; - commonServiceConfig = { name, config, ... }: { - # Try to convert package name to attribute and add it to the - # environment - paths = let - packageAttr = replaceStrings ["_"] ["-"] config.package; - in optional (hasAttr packageAttr cfg.pkgs) cfg.pkgs."${packageAttr}"; - - env = mkDefault (cfg.pkgs.buildEnv { - name = "ros-node-${name}-env"; - inherit (config) paths; - }); - }; - - serviceGenerator = execStartFn: services: mapAttrs' (name: config: nameValuePair name { - serviceConfig = { - Type = "exec"; - StateDirectory = "ros"; - WorkingDirectory = "/var/lib/ros"; - User = "ros"; - Group = "ros"; - ExecStart = execStartFn config; - }; - wantedBy = [ "multi-user.target" ]; - environment = { - ROS_DOMAIN_ID = toString cfg.domainId; - ROS_HOME = "/var/lib/ros"; + commonServiceConfig = + { name, config, ... }: + { + # Try to convert package name to attribute and add it to the + # environment + paths = + let + packageAttr = replaceStrings [ "_" ] [ "-" ] config.package; + in + optional (hasAttr packageAttr cfg.pkgs) cfg.pkgs."${packageAttr}"; + + env = mkDefault ( + cfg.pkgs.buildEnv { + name = "ros-node-${name}-env"; + inherit (config) paths; + } + ); }; - }) services; -in { + + serviceGenerator = + execStartFn: services: + mapAttrs' ( + name: config: + nameValuePair name { + serviceConfig = { + Type = "exec"; + StateDirectory = "ros"; + WorkingDirectory = "/var/lib/ros"; + User = "ros"; + Group = "ros"; + ExecStart = execStartFn config; + }; + wantedBy = [ "multi-user.target" ]; + environment = { + ROS_DOMAIN_ID = toString cfg.domainId; + ROS_HOME = "/var/lib/ros"; + }; + } + ) services; +in +{ # Interface options.services.ros2 = { nodes = mkOption { - type = types.attrsOf (types.submodule ({ name, config, ... }@args: { - options = commonServiceOptions // { - node = mkOption { - type = types.str; - description = '' - Name of the node to launch. - ''; - }; - - args = mkOption { - type = types.listOf types.str; - default = []; - description = '' - Arguments to pass to the node. - ''; - }; - - rosArgs = mkOption { - type = types.listOf types.str; - default = []; - description = '' - ROS specific arguments to pass to the node using --ros-args - ''; - }; - - params = mkOption { - type = types.attrsOf types.str; - default = {}; - description = '' - Key-value parameters to pass to the node. - ''; - }; - }; - - config = mkMerge [ - (commonServiceConfig args) - { - paths = [ cfg.pkgs.ros2run ]; - rosArgs = flatten (mapAttrsToList (k: v: [ "--param" "${k}:=${v}" ]) config.params); + type = types.attrsOf ( + types.submodule ( + { name, config, ... }@args: + { + options = commonServiceOptions // { + node = mkOption { + type = types.str; + description = '' + Name of the node to launch. + ''; + }; + + args = mkOption { + type = types.listOf types.str; + default = [ ]; + description = '' + Arguments to pass to the node. + ''; + }; + + rosArgs = mkOption { + type = types.listOf types.str; + default = [ ]; + description = '' + ROS specific arguments to pass to the node using --ros-args + ''; + }; + + params = mkOption { + type = types.attrsOf types.str; + default = { }; + description = '' + Key-value parameters to pass to the node. + ''; + }; + }; + + config = mkMerge [ + (commonServiceConfig args) + { + paths = [ cfg.pkgs.ros2run ]; + rosArgs = flatten ( + mapAttrsToList (k: v: [ + "--param" + "${k}:=${v}" + ]) config.params + ); + } + ]; } - ]; - })); - default = {}; + ) + ); + default = { }; description = '' ROS nodes to launch at boot as systemd services. ''; }; launchFiles = mkOption { - type = types.attrsOf (types.submodule ({ name, config, ... }@args: { - options = commonServiceOptions // { - launchFile = mkOption { - type = types.str; - description = '' - Name of the launch file. - ''; - }; - - args = mkOption { - type = types.attrsOf types.str; - default = {}; - description = '' - Key-value arguments to pass to the launch file - ''; - }; - - launchArgs = mkOption { - type = types.listOf types.str; - default = []; - description = '' - Extra command line arguments to pass to ros2 launch. - ''; - }; - }; - - config = mkMerge [ - (commonServiceConfig args) - { paths = with cfg.pkgs; [ cfg.pkgs.ros2launch ]; } - ]; - })); - default = {}; + type = types.attrsOf ( + types.submodule ( + { name, config, ... }@args: + { + options = commonServiceOptions // { + launchFile = mkOption { + type = types.str; + description = '' + Name of the launch file. + ''; + }; + + args = mkOption { + type = types.attrsOf types.str; + default = { }; + description = '' + Key-value arguments to pass to the launch file + ''; + }; + + launchArgs = mkOption { + type = types.listOf types.str; + default = [ ]; + description = '' + Extra command line arguments to pass to ros2 launch. + ''; + }; + }; + + config = mkMerge [ + (commonServiceConfig args) + { paths = with cfg.pkgs; [ cfg.pkgs.ros2launch ]; } + ]; + } + ) + ); + default = { }; description = '' ROS launch files to start at boot as systemd services. ''; @@ -157,17 +189,36 @@ in { config = mkIf cfg.enable { systemd.services = mkMerge [ - (serviceGenerator (config: escapeShellArgs ( - [ "${config.env}/bin/ros2" "run" config.package config.node ] ++ - config.args ++ - [ "--ros-args" ] ++ config.rosArgs ++ [ "--" ] - )) cfg.nodes) - (serviceGenerator (config: escapeShellArgs ( - [ "${config.env}/bin/ros2" "launch" ] ++ - config.launchArgs ++ - [ config.package config.launchFile ] ++ - (mapAttrsToList (n: v: "${n}:=${v}") config.args) - )) cfg.launchFiles) + (serviceGenerator ( + config: + escapeShellArgs ( + [ + "${config.env}/bin/ros2" + "run" + config.package + config.node + ] + ++ config.args + ++ [ "--ros-args" ] + ++ config.rosArgs + ++ [ "--" ] + ) + ) cfg.nodes) + (serviceGenerator ( + config: + escapeShellArgs ( + [ + "${config.env}/bin/ros2" + "launch" + ] + ++ config.launchArgs + ++ [ + config.package + config.launchFile + ] + ++ (mapAttrsToList (n: v: "${n}:=${v}") config.args) + ) + ) cfg.launchFiles) ]; }; } diff --git a/modules/ros2/ros.nix b/modules/ros2/ros.nix index d5fafab68e..69f28487a4 100644 --- a/modules/ros2/ros.nix +++ b/modules/ros2/ros.nix @@ -1,4 +1,9 @@ -{ config, lib, pkgs, ... }: +{ + config, + lib, + pkgs, + ... +}: with lib; @@ -15,7 +20,8 @@ let description = "ROS package set overlay"; check = isFunction; }; -in { +in +{ # Interface options.services.ros2 = { @@ -38,7 +44,7 @@ in { overlays = mkOption { type = types.listOf overlayType; - default = []; + default = [ ]; apply = composeManyExtensions; description = '' Set of package overlays to apply to ROS package set for the configured @@ -56,7 +62,7 @@ in { }; systemPackages = mkOption { - default = p: []; + default = p: [ ]; example = literalExample "p: with p; [ ros2cli ros2run ]"; description = '' Packages to add to a ROS environment that will be added to the system @@ -78,12 +84,16 @@ in { environment.variables.ROS_DOMAIN_ID = toString cfg.domainId; - environment.systemPackages = let - paths = cfg.systemPackages cfg.pkgs; - in mkIf (length paths != 0) [ (cfg.pkgs.buildEnv { - name = "ros2-system-env"; - inherit paths; - extraOutputsToInstall = optional config.environment.enableDebugInfo "debug"; - }) ]; + environment.systemPackages = + let + paths = cfg.systemPackages cfg.pkgs; + in + mkIf (length paths != 0) [ + (cfg.pkgs.buildEnv { + name = "ros2-system-env"; + inherit paths; + extraOutputsToInstall = optional config.environment.enableDebugInfo "debug"; + }) + ]; }; } diff --git a/overlay.nix b/overlay.nix index 9ef470e1e2..ccac10b37f 100644 --- a/overlay.nix +++ b/overlay.nix @@ -1,5 +1,6 @@ -final: prev: with prev.lib; -foldr composeExtensions (_: _: {}) [ +final: prev: +with prev.lib; +foldr composeExtensions (_: _: { }) [ (import ./pkgs) (import ./distros) ] final prev diff --git a/pkgs/cargo-ament-build/Cargo.nix b/pkgs/cargo-ament-build/Cargo.nix index c47f58aea4..9255f5dd5b 100644 --- a/pkgs/cargo-ament-build/Cargo.nix +++ b/pkgs/cargo-ament-build/Cargo.nix @@ -1,30 +1,28 @@ - # This file was @generated by crate2nix 0.14.1 with the command: # "generate" # See https://github.com/kolloch/crate2nix for more info. -{ nixpkgs ? -, pkgs ? import nixpkgs { config = {}; } -, lib ? pkgs.lib -, stdenv ? pkgs.stdenv -, buildRustCrateForPkgs ? pkgs: pkgs.buildRustCrate +{ + nixpkgs ? , + pkgs ? import nixpkgs { config = { }; }, + lib ? pkgs.lib, + stdenv ? pkgs.stdenv, + buildRustCrateForPkgs ? pkgs: pkgs.buildRustCrate, # This is used as the `crateOverrides` argument for `buildRustCrate`. -, defaultCrateOverrides ? pkgs.defaultCrateOverrides + defaultCrateOverrides ? pkgs.defaultCrateOverrides, # The features to enable for the root_crate or the workspace_members. -, rootFeatures ? [ "default" ] + rootFeatures ? [ "default" ], # If true, throw errors instead of issueing deprecation warnings. -, strictDeprecation ? false + strictDeprecation ? false, # Elements to add to the `-C target-feature=` argument passed to `rustc` # (separated by `,`, prefixed with `+`). # Used for conditional compilation based on CPU feature detection. -, targetFeatures ? [] + targetFeatures ? [ ], # Whether to perform release builds: longer compile times, faster binaries. -, release ? true + release ? true, # Additional crate2nix configuration if it exists. -, crateConfig - ? if builtins.pathExists ./crate-config.nix - then pkgs.callPackage ./crate-config.nix {} - else {} + crateConfig ? + if builtins.pathExists ./crate-config.nix then pkgs.callPackage ./crate-config.nix { } else { }, }: rec { @@ -63,10 +61,12 @@ rec { # A derivation that joins the outputs of all workspace members together. allWorkspaceMembers = pkgs.symlinkJoin { - name = "all-workspace-members"; - paths = - let members = builtins.attrValues workspaceMembers; - in builtins.map (m: m.build) members; + name = "all-workspace-members"; + paths = + let + members = builtins.attrValues workspaceMembers; + in + builtins.map (m: m.build) members; }; # @@ -97,7 +97,10 @@ rec { "backtrace" = [ "dep:backtrace" ]; "default" = [ "std" ]; }; - resolvedDefaultFeatures = [ "default" "std" ]; + resolvedDefaultFeatures = [ + "default" + "std" + ]; }; "autocfg" = rec { crateName = "autocfg"; @@ -120,7 +123,10 @@ rec { requiredFeatures = [ ]; } ]; - src = lib.cleanSourceWith { filter = sourceFilter; src = ./.; }; + src = lib.cleanSourceWith { + filter = sourceFilter; + src = ./.; + }; authors = [ "Nikolai Morin " ]; @@ -181,9 +187,18 @@ rec { "bumpalo" = [ "dep:bumpalo" ]; "compiler_builtins" = [ "dep:compiler_builtins" ]; "core" = [ "dep:core" ]; - "default" = [ "ahash" "inline-more" ]; + "default" = [ + "ahash" + "inline-more" + ]; "rayon" = [ "dep:rayon" ]; - "rustc-dep-of-std" = [ "nightly" "core" "compiler_builtins" "alloc" "rustc-internal-api" ]; + "rustc-dep-of-std" = [ + "nightly" + "core" + "compiler_builtins" + "alloc" + "rustc-internal-api" + ]; "serde" = [ "dep:serde" ]; }; resolvedDefaultFeatures = [ "raw" ]; @@ -227,7 +242,10 @@ rec { features = { "default" = [ "eq-separator" ]; }; - resolvedDefaultFeatures = [ "default" "eq-separator" ]; + resolvedDefaultFeatures = [ + "default" + "eq-separator" + ]; }; "proc-macro2" = rec { crateName = "proc-macro2"; @@ -303,7 +321,10 @@ rec { "derive" = [ "serde_derive" ]; "serde_derive" = [ "dep:serde_derive" ]; }; - resolvedDefaultFeatures = [ "default" "std" ]; + resolvedDefaultFeatures = [ + "default" + "std" + ]; }; "serde_derive" = rec { crateName = "serde_derive"; @@ -332,11 +353,18 @@ rec { name = "syn"; packageId = "syn"; usesDefaultFeatures = false; - features = [ "clone-impls" "derive" "parsing" "printing" "proc-macro" ]; + features = [ + "clone-impls" + "derive" + "parsing" + "printing" + "proc-macro" + ]; } ]; - features = { - }; + features = + { + }; resolvedDefaultFeatures = [ "default" ]; }; "syn" = rec { @@ -365,12 +393,27 @@ rec { } ]; features = { - "default" = [ "derive" "parsing" "printing" "clone-impls" "proc-macro" ]; + "default" = [ + "derive" + "parsing" + "printing" + "clone-impls" + "proc-macro" + ]; "printing" = [ "dep:quote" ]; - "proc-macro" = [ "proc-macro2/proc-macro" "quote?/proc-macro" ]; + "proc-macro" = [ + "proc-macro2/proc-macro" + "quote?/proc-macro" + ]; "test" = [ "syn-test-suite/all-features" ]; }; - resolvedDefaultFeatures = [ "clone-impls" "derive" "parsing" "printing" "proc-macro" ]; + resolvedDefaultFeatures = [ + "clone-impls" + "derive" + "parsing" + "printing" + "proc-macro" + ]; }; "toml" = rec { crateName = "toml"; @@ -395,7 +438,11 @@ rec { "indexmap" = [ "dep:indexmap" ]; "preserve_order" = [ "indexmap" ]; }; - resolvedDefaultFeatures = [ "default" "indexmap" "preserve_order" ]; + resolvedDefaultFeatures = [ + "default" + "indexmap" + "preserve_order" + ]; }; "unicode-ident" = rec { crateName = "unicode-ident"; @@ -411,45 +458,47 @@ rec { }; # -# crate2nix/default.nix (excerpt start) -# + # crate2nix/default.nix (excerpt start) + # - /* Target (platform) data for conditional dependencies. - This corresponds roughly to what buildRustCrate is setting. - */ - makeDefaultTarget = platform: { - unix = platform.isUnix; - windows = platform.isWindows; - fuchsia = true; - test = false; + /* + Target (platform) data for conditional dependencies. + This corresponds roughly to what buildRustCrate is setting. + */ + makeDefaultTarget = platform: { + unix = platform.isUnix; + windows = platform.isWindows; + fuchsia = true; + test = false; - inherit (platform.rust.platform) - arch - os - vendor; - family = platform.rust.platform.target-family; - env = "gnu"; - endian = - if platform.parsed.cpu.significantByte.name == "littleEndian" - then "little" else "big"; - pointer_width = toString platform.parsed.cpu.bits; - debug_assertions = false; - }; + inherit (platform.rust.platform) + arch + os + vendor + ; + family = platform.rust.platform.target-family; + env = "gnu"; + endian = if platform.parsed.cpu.significantByte.name == "littleEndian" then "little" else "big"; + pointer_width = toString platform.parsed.cpu.bits; + debug_assertions = false; + }; - /* Filters common temp files and build files. */ - # TODO(pkolloch): Substitute with gitignore filter - sourceFilter = name: type: - let - baseName = builtins.baseNameOf (builtins.toString name); - in - ! ( + # Filters common temp files and build files. + # TODO(pkolloch): Substitute with gitignore filter + sourceFilter = + name: type: + let + baseName = builtins.baseNameOf (builtins.toString name); + in + !( # Filter out git baseName == ".gitignore" || (type == "directory" && baseName == ".git") # Filter out build results || ( - type == "directory" && ( + type == "directory" + && ( baseName == "target" || baseName == "_site" || baseName == ".sass-cache" @@ -459,16 +508,11 @@ rec { ) # Filter out nix-build result symlinks - || ( - type == "symlink" && lib.hasPrefix "result" baseName - ) + || (type == "symlink" && lib.hasPrefix "result" baseName) # Filter out IDE config - || ( - type == "directory" && ( - baseName == ".idea" || baseName == ".vscode" - ) - ) || lib.hasSuffix ".iml" baseName + || (type == "directory" && (baseName == ".idea" || baseName == ".vscode")) + || lib.hasSuffix ".iml" baseName # Filter out nix build files || baseName == "Cargo.nix" @@ -482,174 +526,205 @@ rec { || baseName == "tests.nix" ); - /* Returns a crate which depends on successful test execution - of crate given as the second argument. + /* + Returns a crate which depends on successful test execution + of crate given as the second argument. - testCrateFlags: list of flags to pass to the test exectuable - testInputs: list of packages that should be available during test execution - */ - crateWithTest = { crate, testCrate, testCrateFlags, testInputs, testPreRun, testPostRun }: - assert builtins.typeOf testCrateFlags == "list"; - assert builtins.typeOf testInputs == "list"; - assert builtins.typeOf testPreRun == "string"; - assert builtins.typeOf testPostRun == "string"; - let - # override the `crate` so that it will build and execute tests instead of - # building the actual lib and bin targets We just have to pass `--test` - # to rustc and it will do the right thing. We execute the tests and copy - # their log and the test executables to $out for later inspection. - test = - let - drv = testCrate.override - ( - _: { - buildTests = true; - } + testCrateFlags: list of flags to pass to the test exectuable + testInputs: list of packages that should be available during test execution + */ + crateWithTest = + { + crate, + testCrate, + testCrateFlags, + testInputs, + testPreRun, + testPostRun, + }: + assert builtins.typeOf testCrateFlags == "list"; + assert builtins.typeOf testInputs == "list"; + assert builtins.typeOf testPreRun == "string"; + assert builtins.typeOf testPostRun == "string"; + let + # override the `crate` so that it will build and execute tests instead of + # building the actual lib and bin targets We just have to pass `--test` + # to rustc and it will do the right thing. We execute the tests and copy + # their log and the test executables to $out for later inspection. + test = + let + drv = testCrate.override (_: { + buildTests = true; + }); + # If the user hasn't set any pre/post commands, we don't want to + # insert empty lines. This means that any existing users of crate2nix + # don't get a spurious rebuild unless they set these explicitly. + testCommand = pkgs.lib.concatStringsSep "\n" ( + pkgs.lib.filter (s: s != "") [ + testPreRun + "$f $testCrateFlags 2>&1 | tee -a $out" + testPostRun + ] ); - # If the user hasn't set any pre/post commands, we don't want to - # insert empty lines. This means that any existing users of crate2nix - # don't get a spurious rebuild unless they set these explicitly. - testCommand = pkgs.lib.concatStringsSep "\n" - (pkgs.lib.filter (s: s != "") [ - testPreRun - "$f $testCrateFlags 2>&1 | tee -a $out" - testPostRun - ]); - in - pkgs.runCommand "run-tests-${testCrate.name}" - { - inherit testCrateFlags; - buildInputs = testInputs; - } '' - set -e + in + pkgs.runCommand "run-tests-${testCrate.name}" + { + inherit testCrateFlags; + buildInputs = testInputs; + } + '' + set -e - export RUST_BACKTRACE=1 + export RUST_BACKTRACE=1 - # recreate a file hierarchy as when running tests with cargo + # recreate a file hierarchy as when running tests with cargo - # the source for test data - # It's necessary to locate the source in $NIX_BUILD_TOP/source/ - # instead of $NIX_BUILD_TOP/ - # because we compiled those test binaries in the former and not the latter. - # So all paths will expect source tree to be there and not in the build top directly. - # For example: $NIX_BUILD_TOP := /build in general, if you ask yourself. - # NOTE: There could be edge cases if `crate.sourceRoot` does exist but - # it's very hard to reason about them. - # Open a bug if you run into this! - mkdir -p source/ - cd source/ + # the source for test data + # It's necessary to locate the source in $NIX_BUILD_TOP/source/ + # instead of $NIX_BUILD_TOP/ + # because we compiled those test binaries in the former and not the latter. + # So all paths will expect source tree to be there and not in the build top directly. + # For example: $NIX_BUILD_TOP := /build in general, if you ask yourself. + # NOTE: There could be edge cases if `crate.sourceRoot` does exist but + # it's very hard to reason about them. + # Open a bug if you run into this! + mkdir -p source/ + cd source/ - ${pkgs.buildPackages.xorg.lndir}/bin/lndir ${crate.src} + ${pkgs.buildPackages.xorg.lndir}/bin/lndir ${crate.src} - # build outputs - testRoot=target/debug - mkdir -p $testRoot + # build outputs + testRoot=target/debug + mkdir -p $testRoot - # executables of the crate - # we copy to prevent std::env::current_exe() to resolve to a store location - for i in ${crate}/bin/*; do - cp "$i" "$testRoot" - done - chmod +w -R . + # executables of the crate + # we copy to prevent std::env::current_exe() to resolve to a store location + for i in ${crate}/bin/*; do + cp "$i" "$testRoot" + done + chmod +w -R . - # test harness executables are suffixed with a hash, like cargo does - # this allows to prevent name collision with the main - # executables of the crate - hash=$(basename $out) - for file in ${drv}/tests/*; do - f=$testRoot/$(basename $file)-$hash - cp $file $f - ${testCommand} - done - ''; - in - pkgs.runCommand "${crate.name}-linked" - { - inherit (crate) outputs crateName; - passthru = (crate.passthru or { }) // { - inherit test; - }; - } - (lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) '' - echo tested by ${test} - '' + '' - ${lib.concatMapStringsSep "\n" (output: "ln -s ${crate.${output}} ${"$"}${output}") crate.outputs} - ''); - - /* A restricted overridable version of builtRustCratesWithFeatures. */ - buildRustCrateWithFeatures = - { packageId - , features ? rootFeatures - , crateOverrides ? defaultCrateOverrides - , buildRustCrateForPkgsFunc ? null - , runTests ? false - , testCrateFlags ? [ ] - , testInputs ? [ ] - # Any command to run immediatelly before a test is executed. - , testPreRun ? "" - # Any command run immediatelly after a test is executed. - , testPostRun ? "" - }: - lib.makeOverridable - ( - { features - , crateOverrides - , runTests - , testCrateFlags - , testInputs - , testPreRun - , testPostRun - }: - let - buildRustCrateForPkgsFuncOverriden = - if buildRustCrateForPkgsFunc != null - then buildRustCrateForPkgsFunc - else - ( - if crateOverrides == pkgs.defaultCrateOverrides - then buildRustCrateForPkgs - else - pkgs: (buildRustCrateForPkgs pkgs).override { - defaultCrateOverrides = crateOverrides; - } - ); - builtRustCrates = builtRustCratesWithFeatures { - inherit packageId features; - buildRustCrateForPkgsFunc = buildRustCrateForPkgsFuncOverriden; - runTests = false; - }; - builtTestRustCrates = builtRustCratesWithFeatures { - inherit packageId features; - buildRustCrateForPkgsFunc = buildRustCrateForPkgsFuncOverriden; - runTests = true; + # test harness executables are suffixed with a hash, like cargo does + # this allows to prevent name collision with the main + # executables of the crate + hash=$(basename $out) + for file in ${drv}/tests/*; do + f=$testRoot/$(basename $file)-$hash + cp $file $f + ${testCommand} + done + ''; + in + pkgs.runCommand "${crate.name}-linked" + { + inherit (crate) outputs crateName; + passthru = (crate.passthru or { }) // { + inherit test; }; - drv = builtRustCrates.crates.${packageId}; - testDrv = builtTestRustCrates.crates.${packageId}; - derivation = - if runTests then - crateWithTest - { + } + ( + lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) '' + echo tested by ${test} + '' + + '' + ${lib.concatMapStringsSep "\n" (output: "ln -s ${crate.${output}} ${"$"}${output}") crate.outputs} + '' + ); + + # A restricted overridable version of builtRustCratesWithFeatures. + buildRustCrateWithFeatures = + { + packageId, + features ? rootFeatures, + crateOverrides ? defaultCrateOverrides, + buildRustCrateForPkgsFunc ? null, + runTests ? false, + testCrateFlags ? [ ], + testInputs ? [ ], + # Any command to run immediatelly before a test is executed. + testPreRun ? "", + # Any command run immediatelly after a test is executed. + testPostRun ? "", + }: + lib.makeOverridable + ( + { + features, + crateOverrides, + runTests, + testCrateFlags, + testInputs, + testPreRun, + testPostRun, + }: + let + buildRustCrateForPkgsFuncOverriden = + if buildRustCrateForPkgsFunc != null then + buildRustCrateForPkgsFunc + else + ( + if crateOverrides == pkgs.defaultCrateOverrides then + buildRustCrateForPkgs + else + pkgs: + (buildRustCrateForPkgs pkgs).override { + defaultCrateOverrides = crateOverrides; + } + ); + builtRustCrates = builtRustCratesWithFeatures { + inherit packageId features; + buildRustCrateForPkgsFunc = buildRustCrateForPkgsFuncOverriden; + runTests = false; + }; + builtTestRustCrates = builtRustCratesWithFeatures { + inherit packageId features; + buildRustCrateForPkgsFunc = buildRustCrateForPkgsFuncOverriden; + runTests = true; + }; + drv = builtRustCrates.crates.${packageId}; + testDrv = builtTestRustCrates.crates.${packageId}; + derivation = + if runTests then + crateWithTest { crate = drv; testCrate = testDrv; - inherit testCrateFlags testInputs testPreRun testPostRun; + inherit + testCrateFlags + testInputs + testPreRun + testPostRun + ; } - else drv; - in - derivation - ) - { inherit features crateOverrides runTests testCrateFlags testInputs testPreRun testPostRun; }; + else + drv; + in + derivation + ) + { + inherit + features + crateOverrides + runTests + testCrateFlags + testInputs + testPreRun + testPostRun + ; + }; - /* Returns an attr set with packageId mapped to the result of buildRustCrateForPkgsFunc - for the corresponding crate. - */ - builtRustCratesWithFeatures = - { packageId - , features - , crateConfigs ? crates - , buildRustCrateForPkgsFunc - , runTests - , makeTarget ? makeDefaultTarget - } @ args: + /* + Returns an attr set with packageId mapped to the result of buildRustCrateForPkgsFunc + for the corresponding crate. + */ + builtRustCratesWithFeatures = + { + packageId, + features, + crateConfigs ? crates, + buildRustCrateForPkgsFunc, + runTests, + makeTarget ? makeDefaultTarget, + }@args: assert (builtins.isAttrs crateConfigs); assert (builtins.isString packageId); assert (builtins.isList features); @@ -657,55 +732,59 @@ rec { assert (builtins.isBool runTests); let rootPackageId = packageId; - mergedFeatures = mergePackageFeatures - ( - args // { - inherit rootPackageId; - target = makeTarget stdenv.hostPlatform // { test = runTests; }; - } - ); + mergedFeatures = mergePackageFeatures ( + args + // { + inherit rootPackageId; + target = makeTarget stdenv.hostPlatform // { + test = runTests; + }; + } + ); # Memoize built packages so that reappearing packages are only built once. builtByPackageIdByPkgs = mkBuiltByPackageIdByPkgs pkgs; - mkBuiltByPackageIdByPkgs = pkgs: + mkBuiltByPackageIdByPkgs = + pkgs: let self = { - crates = lib.mapAttrs (packageId: value: buildByPackageIdForPkgsImpl self pkgs packageId) crateConfigs; + crates = lib.mapAttrs ( + packageId: value: buildByPackageIdForPkgsImpl self pkgs packageId + ) crateConfigs; target = makeTarget stdenv.hostPlatform; build = mkBuiltByPackageIdByPkgs pkgs.buildPackages; }; in self; - buildByPackageIdForPkgsImpl = self: pkgs: packageId: + buildByPackageIdForPkgsImpl = + self: pkgs: packageId: let features = mergedFeatures."${packageId}" or [ ]; crateConfig' = crateConfigs."${packageId}"; - crateConfig = - builtins.removeAttrs crateConfig' [ "resolvedDefaultFeatures" "devDependencies" ]; - devDependencies = - lib.optionals - (runTests && packageId == rootPackageId) - (crateConfig'.devDependencies or [ ]); - dependencies = - dependencyDerivations { - inherit features; - inherit (self) target; - buildByPackageId = depPackageId: - # proc_macro crates must be compiled for the build architecture - if crateConfigs.${depPackageId}.procMacro or false - then self.build.crates.${depPackageId} - else self.crates.${depPackageId}; - dependencies = - (crateConfig.dependencies or [ ]) - ++ devDependencies; - }; - buildDependencies = - dependencyDerivations { - inherit features; - inherit (self.build) target; - buildByPackageId = depPackageId: - self.build.crates.${depPackageId}; - dependencies = crateConfig.buildDependencies or [ ]; - }; + crateConfig = builtins.removeAttrs crateConfig' [ + "resolvedDefaultFeatures" + "devDependencies" + ]; + devDependencies = lib.optionals (runTests && packageId == rootPackageId) ( + crateConfig'.devDependencies or [ ] + ); + dependencies = dependencyDerivations { + inherit features; + inherit (self) target; + buildByPackageId = + depPackageId: + # proc_macro crates must be compiled for the build architecture + if crateConfigs.${depPackageId}.procMacro or false then + self.build.crates.${depPackageId} + else + self.crates.${depPackageId}; + dependencies = (crateConfig.dependencies or [ ]) ++ devDependencies; + }; + buildDependencies = dependencyDerivations { + inherit features; + inherit (self.build) target; + buildByPackageId = depPackageId: self.build.crates.${depPackageId}; + dependencies = crateConfig.buildDependencies or [ ]; + }; dependenciesWithRenames = let buildDeps = filterEnabledDependencies { @@ -730,46 +809,55 @@ rec { # } crateRenames = let - grouped = - lib.groupBy - (dependency: dependency.name) - dependenciesWithRenames; - versionAndRename = dep: + grouped = lib.groupBy (dependency: dependency.name) dependenciesWithRenames; + versionAndRename = + dep: let package = crateConfigs."${dep.packageId}"; in - { inherit (dep) rename; inherit (package) version; }; + { + inherit (dep) rename; + inherit (package) version; + }; in lib.mapAttrs (name: builtins.map versionAndRename) grouped; in - buildRustCrateForPkgsFunc pkgs - ( - crateConfig // { - src = crateConfig.src or ( - pkgs.fetchurl rec { - name = "${crateConfig.crateName}-${crateConfig.version}.tar.gz"; - # https://www.pietroalbini.org/blog/downloading-crates-io/ - # Not rate-limited, CDN URL. - url = "https://static.crates.io/crates/${crateConfig.crateName}/${crateConfig.crateName}-${crateConfig.version}.crate"; - sha256 = - assert (lib.assertMsg (crateConfig ? sha256) "Missing sha256 for ${name}"); - crateConfig.sha256; - } - ); - extraRustcOpts = lib.lists.optional (targetFeatures != [ ]) "-C target-feature=${lib.concatMapStringsSep "," (x: "+${x}") targetFeatures}"; - inherit features dependencies buildDependencies crateRenames release; - } - ); + buildRustCrateForPkgsFunc pkgs ( + crateConfig + // { + src = + crateConfig.src or (pkgs.fetchurl rec { + name = "${crateConfig.crateName}-${crateConfig.version}.tar.gz"; + # https://www.pietroalbini.org/blog/downloading-crates-io/ + # Not rate-limited, CDN URL. + url = "https://static.crates.io/crates/${crateConfig.crateName}/${crateConfig.crateName}-${crateConfig.version}.crate"; + sha256 = + assert (lib.assertMsg (crateConfig ? sha256) "Missing sha256 for ${name}"); + crateConfig.sha256; + }); + extraRustcOpts = + lib.lists.optional (targetFeatures != [ ]) + "-C target-feature=${lib.concatMapStringsSep "," (x: "+${x}") targetFeatures}"; + inherit + features + dependencies + buildDependencies + crateRenames + release + ; + } + ); in builtByPackageIdByPkgs; - /* Returns the actual derivations for the given dependencies. */ - dependencyDerivations = - { buildByPackageId - , features - , dependencies - , target - }: + # Returns the actual derivations for the given dependencies. + dependencyDerivations = + { + buildByPackageId, + features, + dependencies, + target, + }: assert (builtins.isList features); assert (builtins.isList dependencies); assert (builtins.isAttrs target); @@ -781,106 +869,117 @@ rec { in map depDerivation enabledDependencies; - /* Returns a sanitized version of val with all values substituted that cannot - be serialized as JSON. - */ - sanitizeForJson = val: - if builtins.isAttrs val - then lib.mapAttrs (n: sanitizeForJson) val - else if builtins.isList val - then builtins.map sanitizeForJson val - else if builtins.isFunction val - then "function" - else val; + /* + Returns a sanitized version of val with all values substituted that cannot + be serialized as JSON. + */ + sanitizeForJson = + val: + if builtins.isAttrs val then + lib.mapAttrs (n: sanitizeForJson) val + else if builtins.isList val then + builtins.map sanitizeForJson val + else if builtins.isFunction val then + "function" + else + val; - /* Returns various tools to debug a crate. */ - debugCrate = { packageId, target ? makeDefaultTarget stdenv.hostPlatform }: - assert (builtins.isString packageId); - let - debug = rec { - # The built tree as passed to buildRustCrate. - buildTree = buildRustCrateWithFeatures { - buildRustCrateForPkgsFunc = _: lib.id; - inherit packageId; - }; - sanitizedBuildTree = sanitizeForJson buildTree; - dependencyTree = sanitizeForJson - ( - buildRustCrateWithFeatures { - buildRustCrateForPkgsFunc = _: crate: { - "01_crateName" = crate.crateName or false; - "02_features" = crate.features or [ ]; - "03_dependencies" = crate.dependencies or [ ]; - }; - inherit packageId; - } - ); - mergedPackageFeatures = mergePackageFeatures { - features = rootFeatures; - inherit packageId target; - }; - diffedDefaultPackageFeatures = diffDefaultPackageFeatures { - inherit packageId target; + # Returns various tools to debug a crate. + debugCrate = + { + packageId, + target ? makeDefaultTarget stdenv.hostPlatform, + }: + assert (builtins.isString packageId); + let + debug = rec { + # The built tree as passed to buildRustCrate. + buildTree = buildRustCrateWithFeatures { + buildRustCrateForPkgsFunc = _: lib.id; + inherit packageId; + }; + sanitizedBuildTree = sanitizeForJson buildTree; + dependencyTree = sanitizeForJson (buildRustCrateWithFeatures { + buildRustCrateForPkgsFunc = _: crate: { + "01_crateName" = crate.crateName or false; + "02_features" = crate.features or [ ]; + "03_dependencies" = crate.dependencies or [ ]; + }; + inherit packageId; + }); + mergedPackageFeatures = mergePackageFeatures { + features = rootFeatures; + inherit packageId target; + }; + diffedDefaultPackageFeatures = diffDefaultPackageFeatures { + inherit packageId target; + }; }; + in + { + internal = debug; }; - in - { internal = debug; }; - /* Returns differences between cargo default features and crate2nix default - features. + /* + Returns differences between cargo default features and crate2nix default + features. - This is useful for verifying the feature resolution in crate2nix. - */ - diffDefaultPackageFeatures = - { crateConfigs ? crates - , packageId - , target - }: + This is useful for verifying the feature resolution in crate2nix. + */ + diffDefaultPackageFeatures = + { + crateConfigs ? crates, + packageId, + target, + }: assert (builtins.isAttrs crateConfigs); let prefixValues = prefix: lib.mapAttrs (n: v: { "${prefix}" = v; }); - mergedFeatures = - prefixValues - "crate2nix" - (mergePackageFeatures { inherit crateConfigs packageId target; features = [ "default" ]; }); + mergedFeatures = prefixValues "crate2nix" (mergePackageFeatures { + inherit crateConfigs packageId target; + features = [ "default" ]; + }); configs = prefixValues "cargo" crateConfigs; - combined = lib.foldAttrs (a: b: a // b) { } [ mergedFeatures configs ]; - onlyInCargo = - builtins.attrNames - (lib.filterAttrs (n: v: !(v ? "crate2nix") && (v ? "cargo")) combined); - onlyInCrate2Nix = - builtins.attrNames - (lib.filterAttrs (n: v: (v ? "crate2nix") && !(v ? "cargo")) combined); - differentFeatures = lib.filterAttrs - ( - n: v: - (v ? "crate2nix") - && (v ? "cargo") - && (v.crate2nix.features or [ ]) != (v."cargo".resolved_default_features or [ ]) - ) - combined; + combined = lib.foldAttrs (a: b: a // b) { } [ + mergedFeatures + configs + ]; + onlyInCargo = builtins.attrNames ( + lib.filterAttrs (n: v: !(v ? "crate2nix") && (v ? "cargo")) combined + ); + onlyInCrate2Nix = builtins.attrNames ( + lib.filterAttrs (n: v: (v ? "crate2nix") && !(v ? "cargo")) combined + ); + differentFeatures = lib.filterAttrs ( + n: v: + (v ? "crate2nix") + && (v ? "cargo") + && (v.crate2nix.features or [ ]) != (v."cargo".resolved_default_features or [ ]) + ) combined; in builtins.toJSON { inherit onlyInCargo onlyInCrate2Nix differentFeatures; }; - /* Returns an attrset mapping packageId to the list of enabled features. + /* + Returns an attrset mapping packageId to the list of enabled features. - If multiple paths to a dependency enable different features, the - corresponding feature sets are merged. Features in rust are additive. - */ - mergePackageFeatures = - { crateConfigs ? crates - , packageId - , rootPackageId ? packageId - , features ? rootFeatures - , dependencyPath ? [ crates.${packageId}.crateName ] - , featuresByPackageId ? { } - , target - # Adds devDependencies to the crate with rootPackageId. - , runTests ? false - , ... - } @ args: + If multiple paths to a dependency enable different features, the + corresponding feature sets are merged. Features in rust are additive. + */ + mergePackageFeatures = + { + crateConfigs ? crates, + packageId, + rootPackageId ? packageId, + features ? rootFeatures, + dependencyPath ? [ crates.${packageId}.crateName ], + featuresByPackageId ? { }, + target, + # Adds devDependencies to the crate with rootPackageId. + runTests ? false, + ... + }@args: assert (builtins.isAttrs crateConfigs); assert (builtins.isString packageId); assert (builtins.isString rootPackageId); @@ -893,13 +992,17 @@ rec { crateConfig = crateConfigs."${packageId}" or (builtins.throw "Package not found: ${packageId}"); expandedFeatures = expandFeatures (crateConfig.features or { }) features; enabledFeatures = enableFeatures (crateConfig.dependencies or [ ]) expandedFeatures; - depWithResolvedFeatures = dependency: + depWithResolvedFeatures = + dependency: let inherit (dependency) packageId; features = dependencyFeatures enabledFeatures dependency; in - { inherit packageId features; }; - resolveDependencies = cache: path: dependencies: + { + inherit packageId features; + }; + resolveDependencies = + cache: path: dependencies: assert (builtins.isAttrs cache); assert (builtins.isList dependencies); let @@ -910,182 +1013,189 @@ rec { directDependencies = map depWithResolvedFeatures enabledDependencies; foldOverCache = op: lib.foldl op cache directDependencies; in - foldOverCache - ( - cache: { packageId, features }: - let - cacheFeatures = cache.${packageId} or [ ]; - combinedFeatures = sortedUnique (cacheFeatures ++ features); - in - if cache ? ${packageId} && cache.${packageId} == combinedFeatures - then cache - else - mergePackageFeatures { - features = combinedFeatures; - featuresByPackageId = cache; - inherit crateConfigs packageId target runTests rootPackageId; - } - ); + foldOverCache ( + cache: + { packageId, features }: + let + cacheFeatures = cache.${packageId} or [ ]; + combinedFeatures = sortedUnique (cacheFeatures ++ features); + in + if cache ? ${packageId} && cache.${packageId} == combinedFeatures then + cache + else + mergePackageFeatures { + features = combinedFeatures; + featuresByPackageId = cache; + inherit + crateConfigs + packageId + target + runTests + rootPackageId + ; + } + ); cacheWithSelf = let cacheFeatures = featuresByPackageId.${packageId} or [ ]; combinedFeatures = sortedUnique (cacheFeatures ++ enabledFeatures); in - featuresByPackageId // { + featuresByPackageId + // { "${packageId}" = combinedFeatures; }; - cacheWithDependencies = - resolveDependencies cacheWithSelf "dep" - ( - crateConfig.dependencies or [ ] - ++ lib.optionals - (runTests && packageId == rootPackageId) - (crateConfig.devDependencies or [ ]) - ); - cacheWithAll = - resolveDependencies - cacheWithDependencies "build" - (crateConfig.buildDependencies or [ ]); + cacheWithDependencies = resolveDependencies cacheWithSelf "dep" ( + crateConfig.dependencies or [ ] + ++ lib.optionals (runTests && packageId == rootPackageId) (crateConfig.devDependencies or [ ]) + ); + cacheWithAll = resolveDependencies cacheWithDependencies "build" ( + crateConfig.buildDependencies or [ ] + ); in cacheWithAll; - /* Returns the enabled dependencies given the enabled features. */ - filterEnabledDependencies = { dependencies, features, target }: - assert (builtins.isList dependencies); - assert (builtins.isList features); - assert (builtins.isAttrs target); + # Returns the enabled dependencies given the enabled features. + filterEnabledDependencies = + { + dependencies, + features, + target, + }: + assert (builtins.isList dependencies); + assert (builtins.isList features); + assert (builtins.isAttrs target); - lib.filter - ( + lib.filter ( dep: let targetFunc = dep.target or (features: true); in targetFunc { inherit features target; } - && ( - !(dep.optional or false) - || builtins.any (doesFeatureEnableDependency dep) features - ) - ) - dependencies; + && (!(dep.optional or false) || builtins.any (doesFeatureEnableDependency dep) features) + ) dependencies; - /* Returns whether the given feature should enable the given dependency. */ - doesFeatureEnableDependency = dependency: feature: - let - name = dependency.rename or dependency.name; - prefix = "${name}/"; - len = builtins.stringLength prefix; - startsWithPrefix = builtins.substring 0 len feature == prefix; - in - feature == name || feature == "dep:" + name || startsWithPrefix; - - /* Returns the expanded features for the given inputFeatures by applying the - rules in featureMap. + # Returns whether the given feature should enable the given dependency. + doesFeatureEnableDependency = + dependency: feature: + let + name = dependency.rename or dependency.name; + prefix = "${name}/"; + len = builtins.stringLength prefix; + startsWithPrefix = builtins.substring 0 len feature == prefix; + in + feature == name || feature == "dep:" + name || startsWithPrefix; - featureMap is an attribute set which maps feature names to lists of further - feature names to enable in case this feature is selected. - */ - expandFeatures = featureMap: inputFeatures: - assert (builtins.isAttrs featureMap); - assert (builtins.isList inputFeatures); - let - expandFeaturesNoCycle = oldSeen: inputFeatures: - if inputFeatures != [ ] - then - let - # The feature we're currently expanding. - feature = builtins.head inputFeatures; - # All the features we've seen/expanded so far, including the one - # we're currently processing. - seen = oldSeen // { ${feature} = 1; }; - # Expand the feature but be careful to not re-introduce a feature - # that we've already seen: this can easily cause a cycle, see issue - # #209. - enables = builtins.filter (f: !(seen ? "${f}")) (featureMap."${feature}" or [ ]); - in - [ feature ] ++ (expandFeaturesNoCycle seen (builtins.tail inputFeatures ++ enables)) - # No more features left, nothing to expand to. - else [ ]; - outFeatures = expandFeaturesNoCycle { } inputFeatures; - in - sortedUnique outFeatures; + /* + Returns the expanded features for the given inputFeatures by applying the + rules in featureMap. - /* This function adds optional dependencies as features if they are enabled - indirectly by dependency features. This function mimics Cargo's behavior - described in a note at: - https://doc.rust-lang.org/nightly/cargo/reference/features.html#dependency-features - */ - enableFeatures = dependencies: features: - assert (builtins.isList features); - assert (builtins.isList dependencies); - let - additionalFeatures = lib.concatMap - ( - dependency: - assert (builtins.isAttrs dependency); + featureMap is an attribute set which maps feature names to lists of further + feature names to enable in case this feature is selected. + */ + expandFeatures = + featureMap: inputFeatures: + assert (builtins.isAttrs featureMap); + assert (builtins.isList inputFeatures); + let + expandFeaturesNoCycle = + oldSeen: inputFeatures: + if inputFeatures != [ ] then let - enabled = builtins.any (doesFeatureEnableDependency dependency) features; + # The feature we're currently expanding. + feature = builtins.head inputFeatures; + # All the features we've seen/expanded so far, including the one + # we're currently processing. + seen = oldSeen // { + ${feature} = 1; + }; + # Expand the feature but be careful to not re-introduce a feature + # that we've already seen: this can easily cause a cycle, see issue + # #209. + enables = builtins.filter (f: !(seen ? "${f}")) (featureMap."${feature}" or [ ]); in - if (dependency.optional or false) && enabled - then [ (dependency.rename or dependency.name) ] - else [ ] - ) - dependencies; - in - sortedUnique (features ++ additionalFeatures); + [ feature ] ++ (expandFeaturesNoCycle seen (builtins.tail inputFeatures ++ enables)) + # No more features left, nothing to expand to. + else + [ ]; + outFeatures = expandFeaturesNoCycle { } inputFeatures; + in + sortedUnique outFeatures; - /* - Returns the actual features for the given dependency. + /* + This function adds optional dependencies as features if they are enabled + indirectly by dependency features. This function mimics Cargo's behavior + described in a note at: + https://doc.rust-lang.org/nightly/cargo/reference/features.html#dependency-features + */ + enableFeatures = + dependencies: features: + assert (builtins.isList features); + assert (builtins.isList dependencies); + let + additionalFeatures = lib.concatMap ( + dependency: + assert (builtins.isAttrs dependency); + let + enabled = builtins.any (doesFeatureEnableDependency dependency) features; + in + if (dependency.optional or false) && enabled then + [ (dependency.rename or dependency.name) ] + else + [ ] + ) dependencies; + in + sortedUnique (features ++ additionalFeatures); - features: The features of the crate that refers this dependency. - */ - dependencyFeatures = features: dependency: - assert (builtins.isList features); - assert (builtins.isAttrs dependency); - let - defaultOrNil = - if dependency.usesDefaultFeatures or true - then [ "default" ] - else [ ]; - explicitFeatures = dependency.features or [ ]; - additionalDependencyFeatures = - let - name = dependency.rename or dependency.name; - stripPrefixMatch = prefix: s: - if lib.hasPrefix prefix s - then lib.removePrefix prefix s - else null; - extractFeature = feature: lib.findFirst - (f: f != null) - null - (map (prefix: stripPrefixMatch prefix feature) [ - (name + "/") - (name + "?/") - ]); - dependencyFeatures = lib.filter (f: f != null) (map extractFeature features); - in - dependencyFeatures; - in - defaultOrNil ++ explicitFeatures ++ additionalDependencyFeatures; + /* + Returns the actual features for the given dependency. - /* Sorts and removes duplicates from a list of strings. */ - sortedUnique = features: - assert (builtins.isList features); - assert (builtins.all builtins.isString features); - let - outFeaturesSet = lib.foldl (set: feature: set // { "${feature}" = 1; }) { } features; - outFeaturesUnique = builtins.attrNames outFeaturesSet; - in - builtins.sort (a: b: a < b) outFeaturesUnique; + features: The features of the crate that refers this dependency. + */ + dependencyFeatures = + features: dependency: + assert (builtins.isList features); + assert (builtins.isAttrs dependency); + let + defaultOrNil = if dependency.usesDefaultFeatures or true then [ "default" ] else [ ]; + explicitFeatures = dependency.features or [ ]; + additionalDependencyFeatures = + let + name = dependency.rename or dependency.name; + stripPrefixMatch = prefix: s: if lib.hasPrefix prefix s then lib.removePrefix prefix s else null; + extractFeature = + feature: + lib.findFirst (f: f != null) null ( + map (prefix: stripPrefixMatch prefix feature) [ + (name + "/") + (name + "?/") + ] + ); + dependencyFeatures = lib.filter (f: f != null) (map extractFeature features); + in + dependencyFeatures; + in + defaultOrNil ++ explicitFeatures ++ additionalDependencyFeatures; - deprecationWarning = message: value: - if strictDeprecation - then builtins.throw "strictDeprecation enabled, aborting: ${message}" - else builtins.trace message value; + # Sorts and removes duplicates from a list of strings. + sortedUnique = + features: + assert (builtins.isList features); + assert (builtins.all builtins.isString features); + let + outFeaturesSet = lib.foldl (set: feature: set // { "${feature}" = 1; }) { } features; + outFeaturesUnique = builtins.attrNames outFeaturesSet; + in + builtins.sort (a: b: a < b) outFeaturesUnique; - # - # crate2nix/default.nix (excerpt end) - # + deprecationWarning = + message: value: + if strictDeprecation then + builtins.throw "strictDeprecation enabled, aborting: ${message}" + else + builtins.trace message value; + + # + # crate2nix/default.nix (excerpt end) + # }; } - diff --git a/pkgs/cargo-ament-build/default.nix b/pkgs/cargo-ament-build/default.nix index bf1e2a9a7b..d5539dc70a 100644 --- a/pkgs/cargo-ament-build/default.nix +++ b/pkgs/cargo-ament-build/default.nix @@ -1,17 +1,22 @@ { pkgs, fetchFromGitHub }: -(import ./Cargo.nix { inherit pkgs; }).rootCrate.build.override ({ - crateOverrides ? {}, ... -}: { - crateOverrides = crateOverrides // { - cargo-ament-build = { ... }: { - src = fetchFromGitHub { - owner = "ros2-rust"; - repo = "cargo-ament-build"; - rev = "v0.1.8"; - hash = "sha256-P3HX3LXQLA2NvFeV3B1baGrl0CaPWAn4Yzh+aAgUuBM="; - }; +(import ./Cargo.nix { inherit pkgs; }).rootCrate.build.override ( + { + crateOverrides ? { }, + ... + }: + { + crateOverrides = crateOverrides // { + cargo-ament-build = + { ... }: + { + src = fetchFromGitHub { + owner = "ros2-rust"; + repo = "cargo-ament-build"; + rev = "v0.1.8"; + hash = "sha256-P3HX3LXQLA2NvFeV3B1baGrl0CaPWAn4Yzh+aAgUuBM="; + }; + }; }; - }; -}) - + } +) diff --git a/pkgs/catkin-tools/default.nix b/pkgs/catkin-tools/default.nix index d5ef92a0a1..1aac8b400e 100644 --- a/pkgs/catkin-tools/default.nix +++ b/pkgs/catkin-tools/default.nix @@ -1,5 +1,12 @@ -{ lib, buildPythonPackage, fetchPypi, setuptools, osrf-pycommon, pyyaml -, catkin-pkg }: +{ + lib, + buildPythonPackage, + fetchPypi, + setuptools, + osrf-pycommon, + pyyaml, + catkin-pkg, +}: buildPythonPackage rec { pname = "catkin_tools"; @@ -10,7 +17,12 @@ buildPythonPackage rec { hash = "sha256-BjVwOJRD8L5ESOKlZbiuAc/NQdAsvDoU8INr1FiMBjo="; }; - propagatedBuildInputs = [ setuptools osrf-pycommon pyyaml catkin-pkg ]; + propagatedBuildInputs = [ + setuptools + osrf-pycommon + pyyaml + catkin-pkg + ]; # No tests in PyPi tarball doCheck = false; diff --git a/pkgs/colcon/argcomplete.nix b/pkgs/colcon/argcomplete.nix index f18d6b9402..35a6af6b92 100644 --- a/pkgs/colcon/argcomplete.nix +++ b/pkgs/colcon/argcomplete.nix @@ -1,4 +1,10 @@ -{ lib, buildPythonPackage, fetchPypi, colcon-core, argcomplete }: +{ + lib, + buildPythonPackage, + fetchPypi, + colcon-core, + argcomplete, +}: buildPythonPackage rec { pname = "colcon-argcomplete"; @@ -9,7 +15,10 @@ buildPythonPackage rec { hash = "sha256-PnCjK30WuBanxyGCvbIN+YX/wBZ47Jxn1EZZgUphmH0="; }; - propagatedBuildInputs = [ colcon-core argcomplete ]; + propagatedBuildInputs = [ + colcon-core + argcomplete + ]; doCheck = false; diff --git a/pkgs/colcon/bash.nix b/pkgs/colcon/bash.nix index 58583da4c4..fba42be53f 100644 --- a/pkgs/colcon/bash.nix +++ b/pkgs/colcon/bash.nix @@ -1,4 +1,9 @@ -{ lib, buildPythonPackage, fetchPypi, colcon-core }: +{ + lib, + buildPythonPackage, + fetchPypi, + colcon-core, +}: buildPythonPackage rec { pname = "colcon-bash"; diff --git a/pkgs/colcon/cargo.nix b/pkgs/colcon/cargo.nix index fb282ab471..e0bae0bff1 100644 --- a/pkgs/colcon/cargo.nix +++ b/pkgs/colcon/cargo.nix @@ -1,6 +1,16 @@ -{ lib, buildPythonPackage, fetchPypi, catkin-pkg, colcon-cmake -, colcon-core, colcon-pkg-config, colcon-python-setup-py, colcon-recursive-crawl -, colcon-library-path, toml }: +{ + lib, + buildPythonPackage, + fetchPypi, + catkin-pkg, + colcon-cmake, + colcon-core, + colcon-pkg-config, + colcon-python-setup-py, + colcon-recursive-crawl, + colcon-library-path, + toml, +}: buildPythonPackage rec { pname = "colcon-cargo"; diff --git a/pkgs/colcon/cmake.nix b/pkgs/colcon/cmake.nix index 8ba6b94604..a2aaf0e12b 100644 --- a/pkgs/colcon/cmake.nix +++ b/pkgs/colcon/cmake.nix @@ -1,5 +1,12 @@ -{ lib, buildPythonPackage, fetchPypi, colcon-core, colcon-library-path -, colcon-test-result, cmake }: +{ + lib, + buildPythonPackage, + fetchPypi, + colcon-core, + colcon-library-path, + colcon-test-result, + cmake, +}: buildPythonPackage rec { pname = "colcon-cmake"; diff --git a/pkgs/colcon/core.nix b/pkgs/colcon/core.nix index a308b019a3..282174566c 100644 --- a/pkgs/colcon/core.nix +++ b/pkgs/colcon/core.nix @@ -1,31 +1,50 @@ -{ lib, buildPythonApplication, buildPythonPackage, makeWrapper, fetchPypi -, python, distlib, empy_3, pytest, pytest-cov, pytest-repeat -, pytest-rerunfailures, setuptools, pytestCheckHook, flake8, flake8-blind-except -, flake8-docstrings, flake8-import-order, pep8-naming, pylint +{ + lib, + buildPythonApplication, + buildPythonPackage, + makeWrapper, + fetchPypi, + python, + distlib, + empy_3, + pytest, + pytest-cov, + pytest-repeat, + pytest-rerunfailures, + setuptools, + pytestCheckHook, + flake8, + flake8-blind-except, + flake8-docstrings, + flake8-import-order, + pep8-naming, + pylint, }: let - withExtensions = extensions: buildPythonApplication { - pname = "colcon"; - inherit (package) version; - format = "other"; + withExtensions = + extensions: + buildPythonApplication { + pname = "colcon"; + inherit (package) version; + format = "other"; - dontUnpack = true; - dontBuild = true; - doCheck = false; + dontUnpack = true; + dontBuild = true; + doCheck = false; - nativeBuildInputs = [ makeWrapper ]; - buildInputs = [ package ] ++ extensions; + nativeBuildInputs = [ makeWrapper ]; + buildInputs = [ package ] ++ extensions; - installPhase = '' - makeWrapper '${package}/bin/colcon' "$out/bin/colcon" \ - --prefix PYTHONPATH : "$PYTHONPATH" - ''; + installPhase = '' + makeWrapper '${package}/bin/colcon' "$out/bin/colcon" \ + --prefix PYTHONPATH : "$PYTHONPATH" + ''; - passthru = package.passthru // { - withExtensions = moreExtensions: withExtensions (moreExtensions ++ extensions); + passthru = package.passthru // { + withExtensions = moreExtensions: withExtensions (moreExtensions ++ extensions); + }; }; - }; package = buildPythonPackage rec { pname = "colcon-core"; @@ -76,4 +95,5 @@ let maintainers = with maintainers; [ lopsided98 ]; }; }; -in package +in +package diff --git a/pkgs/colcon/defaults.nix b/pkgs/colcon/defaults.nix index aa5617ab5a..dcff320661 100644 --- a/pkgs/colcon/defaults.nix +++ b/pkgs/colcon/defaults.nix @@ -1,4 +1,10 @@ -{ lib, buildPythonPackage, fetchPypi, colcon-core, pyyaml }: +{ + lib, + buildPythonPackage, + fetchPypi, + colcon-core, + pyyaml, +}: buildPythonPackage rec { pname = "colcon-defaults"; diff --git a/pkgs/colcon/devtools.nix b/pkgs/colcon/devtools.nix index e8f6265219..fff8eedf26 100644 --- a/pkgs/colcon/devtools.nix +++ b/pkgs/colcon/devtools.nix @@ -1,4 +1,9 @@ -{ lib, buildPythonPackage, fetchPypi, colcon-core }: +{ + lib, + buildPythonPackage, + fetchPypi, + colcon-core, +}: buildPythonPackage rec { pname = "colcon-devtools"; diff --git a/pkgs/colcon/library-path.nix b/pkgs/colcon/library-path.nix index aa5008ba2f..5386ba97eb 100644 --- a/pkgs/colcon/library-path.nix +++ b/pkgs/colcon/library-path.nix @@ -1,4 +1,9 @@ -{ lib, buildPythonPackage, fetchPypi, colcon-core }: +{ + lib, + buildPythonPackage, + fetchPypi, + colcon-core, +}: buildPythonPackage rec { pname = "colcon-library-path"; diff --git a/pkgs/colcon/metadata.nix b/pkgs/colcon/metadata.nix index 14c5aa69ef..19f2d9abbe 100644 --- a/pkgs/colcon/metadata.nix +++ b/pkgs/colcon/metadata.nix @@ -1,4 +1,10 @@ -{ lib, buildPythonPackage, fetchPypi, colcon-core, pyyaml }: +{ + lib, + buildPythonPackage, + fetchPypi, + colcon-core, + pyyaml, +}: buildPythonPackage rec { pname = "colcon-metadata"; diff --git a/pkgs/colcon/mixin.nix b/pkgs/colcon/mixin.nix index 18324fa810..65b1f9e5b4 100644 --- a/pkgs/colcon/mixin.nix +++ b/pkgs/colcon/mixin.nix @@ -1,4 +1,10 @@ -{ lib, buildPythonPackage, fetchPypi, colcon-core, pyyaml }: +{ + lib, + buildPythonPackage, + fetchPypi, + colcon-core, + pyyaml, +}: buildPythonPackage rec { pname = "colcon-mixin"; diff --git a/pkgs/colcon/notification.nix b/pkgs/colcon/notification.nix index a5eba32f73..90c3836e94 100644 --- a/pkgs/colcon/notification.nix +++ b/pkgs/colcon/notification.nix @@ -1,4 +1,10 @@ -{ lib, buildPythonPackage, fetchPypi, colcon-core, notify2 }: +{ + lib, + buildPythonPackage, + fetchPypi, + colcon-core, + notify2, +}: buildPythonPackage rec { pname = "colcon-notification"; @@ -9,7 +15,10 @@ buildPythonPackage rec { hash = "sha256-xFuJgHOo6YxFGDM7dYf56kmsG8Epp7xOE5AFkFcDH7g="; }; - propagatedBuildInputs = [ colcon-core notify2 ]; + propagatedBuildInputs = [ + colcon-core + notify2 + ]; doCheck = false; diff --git a/pkgs/colcon/output.nix b/pkgs/colcon/output.nix index 5e814639a1..66ac0d2656 100644 --- a/pkgs/colcon/output.nix +++ b/pkgs/colcon/output.nix @@ -1,4 +1,9 @@ -{ lib, buildPythonPackage, fetchPypi, colcon-core }: +{ + lib, + buildPythonPackage, + fetchPypi, + colcon-core, +}: buildPythonPackage rec { pname = "colcon-output"; diff --git a/pkgs/colcon/package-information.nix b/pkgs/colcon/package-information.nix index 8b036ff98a..1ea0cacaed 100644 --- a/pkgs/colcon/package-information.nix +++ b/pkgs/colcon/package-information.nix @@ -1,4 +1,9 @@ -{ lib, buildPythonPackage, fetchPypi, colcon-core }: +{ + lib, + buildPythonPackage, + fetchPypi, + colcon-core, +}: buildPythonPackage rec { pname = "colcon-package-information"; diff --git a/pkgs/colcon/package-selection.nix b/pkgs/colcon/package-selection.nix index 3bdfafd0b0..5a1f968379 100644 --- a/pkgs/colcon/package-selection.nix +++ b/pkgs/colcon/package-selection.nix @@ -1,4 +1,9 @@ -{ lib, buildPythonPackage, fetchPypi, colcon-core }: +{ + lib, + buildPythonPackage, + fetchPypi, + colcon-core, +}: buildPythonPackage rec { pname = "colcon-package-selection"; diff --git a/pkgs/colcon/parallel-executor.nix b/pkgs/colcon/parallel-executor.nix index eec862e5ab..b0ffea9454 100644 --- a/pkgs/colcon/parallel-executor.nix +++ b/pkgs/colcon/parallel-executor.nix @@ -1,4 +1,9 @@ -{ lib, buildPythonPackage, fetchPypi, colcon-core }: +{ + lib, + buildPythonPackage, + fetchPypi, + colcon-core, +}: buildPythonPackage rec { pname = "colcon-parallel-executor"; diff --git a/pkgs/colcon/pkg-config.nix b/pkgs/colcon/pkg-config.nix index 69041c0777..581cbcc85f 100644 --- a/pkgs/colcon/pkg-config.nix +++ b/pkgs/colcon/pkg-config.nix @@ -1,4 +1,9 @@ -{ lib, buildPythonPackage, fetchPypi, colcon-core }: +{ + lib, + buildPythonPackage, + fetchPypi, + colcon-core, +}: buildPythonPackage rec { pname = "colcon-pkg-config"; diff --git a/pkgs/colcon/python-setup-py.nix b/pkgs/colcon/python-setup-py.nix index d96995851e..84b1c4e6c8 100644 --- a/pkgs/colcon/python-setup-py.nix +++ b/pkgs/colcon/python-setup-py.nix @@ -1,4 +1,10 @@ -{ lib, buildPythonPackage, fetchPypi, colcon-core, setuptools }: +{ + lib, + buildPythonPackage, + fetchPypi, + colcon-core, + setuptools, +}: buildPythonPackage rec { pname = "colcon-python-setup-py"; @@ -9,7 +15,10 @@ buildPythonPackage rec { hash = "sha256-TYurLgW6M04p7uNxX73kkCgTQu2OAA4lITDlxRkVODo="; }; - propagatedBuildInputs = [ colcon-core setuptools ]; + propagatedBuildInputs = [ + colcon-core + setuptools + ]; # Requires unpackaged dependencies doCheck = false; diff --git a/pkgs/colcon/recursive-crawl.nix b/pkgs/colcon/recursive-crawl.nix index a1d10a905a..e4761d433f 100644 --- a/pkgs/colcon/recursive-crawl.nix +++ b/pkgs/colcon/recursive-crawl.nix @@ -1,4 +1,9 @@ -{ lib, buildPythonPackage, fetchPypi, colcon-core }: +{ + lib, + buildPythonPackage, + fetchPypi, + colcon-core, +}: buildPythonPackage rec { pname = "colcon-recursive-crawl"; diff --git a/pkgs/colcon/ros-cargo.nix b/pkgs/colcon/ros-cargo.nix index 8509328c56..c38c8fe608 100644 --- a/pkgs/colcon/ros-cargo.nix +++ b/pkgs/colcon/ros-cargo.nix @@ -1,5 +1,12 @@ -{ lib, buildPythonPackage, fetchPypi, colcon-core, colcon-library-path -, colcon-cargo, colcon-ros }: +{ + lib, + buildPythonPackage, + fetchPypi, + colcon-core, + colcon-library-path, + colcon-cargo, + colcon-ros, +}: buildPythonPackage rec { pname = "colcon-ros-cargo"; diff --git a/pkgs/colcon/ros.nix b/pkgs/colcon/ros.nix index 01047f297c..7b6119650e 100644 --- a/pkgs/colcon/ros.nix +++ b/pkgs/colcon/ros.nix @@ -1,6 +1,14 @@ -{ lib, buildPythonPackage, fetchPypi, catkin-pkg, colcon-cmake, colcon-core -, colcon-pkg-config, colcon-python-setup-py -, colcon-recursive-crawl }: +{ + lib, + buildPythonPackage, + fetchPypi, + catkin-pkg, + colcon-cmake, + colcon-core, + colcon-pkg-config, + colcon-python-setup-py, + colcon-recursive-crawl, +}: buildPythonPackage rec { pname = "colcon-ros"; diff --git a/pkgs/colcon/test-result.nix b/pkgs/colcon/test-result.nix index 2901854200..79f1d25a10 100644 --- a/pkgs/colcon/test-result.nix +++ b/pkgs/colcon/test-result.nix @@ -1,4 +1,9 @@ -{ lib, buildPythonPackage, fetchPypi, colcon-core }: +{ + lib, + buildPythonPackage, + fetchPypi, + colcon-core, +}: buildPythonPackage rec { pname = "colcon-test-result"; diff --git a/pkgs/colcon/zsh.nix b/pkgs/colcon/zsh.nix index 0fabc899a3..696c946ec8 100644 --- a/pkgs/colcon/zsh.nix +++ b/pkgs/colcon/zsh.nix @@ -1,4 +1,9 @@ -{ lib, buildPythonPackage, fetchPypi, colcon-core }: +{ + lib, + buildPythonPackage, + fetchPypi, + colcon-core, +}: buildPythonPackage rec { pname = "colcon-zsh"; diff --git a/pkgs/default.nix b/pkgs/default.nix index ce02f5ea7d..b456c0f005 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -1,29 +1,31 @@ self: super: with self.lib; { - inherit (self.python3Packages) bloom; + inherit (self.python3Packages) bloom; cargo-ament-build = self.callPackage ./cargo-ament-build { }; - colcon = with self.python3Packages; colcon-core.withExtensions [ - colcon-argcomplete - colcon-bash - colcon-cmake - colcon-core - colcon-defaults - colcon-devtools - colcon-library-path - colcon-metadata - colcon-mixin - colcon-notification - colcon-output - colcon-package-information - colcon-package-selection - colcon-parallel-executor - colcon-python-setup-py - colcon-recursive-crawl - colcon-ros - colcon-test-result - colcon-zsh - ]; + colcon = + with self.python3Packages; + colcon-core.withExtensions [ + colcon-argcomplete + colcon-bash + colcon-cmake + colcon-core + colcon-defaults + colcon-devtools + colcon-library-path + colcon-metadata + colcon-mixin + colcon-notification + colcon-output + colcon-package-information + colcon-package-selection + colcon-parallel-executor + colcon-python-setup-py + colcon-recursive-crawl + colcon-ros + colcon-test-result + colcon-zsh + ]; gazebo_11 = self.libsForQt5.callPackage ./gazebo { }; gazebo = self.gazebo_11; @@ -124,17 +126,21 @@ self: super: with self.lib; { colcon-zsh = pyFinal.callPackage ./colcon/zsh.nix { }; - empy_3 = pyPrev.empy.overrideAttrs ({ - pname, ... - }: rec { - version = "3.3.4"; - src = pyFinal.fetchPypi { - inherit pname version; - hash = "sha256-c6xJeFtgFHnfTqGKfHm8EwSop8NMArlHLPEgauiPAbM="; - }; - }); - - osrf-pycommon = pyFinal.callPackage ./osrf-pycommon {}; + empy_3 = pyPrev.empy.overrideAttrs ( + { + pname, + ... + }: + rec { + version = "3.3.4"; + src = pyFinal.fetchPypi { + inherit pname version; + hash = "sha256-c6xJeFtgFHnfTqGKfHm8EwSop8NMArlHLPEgauiPAbM="; + }; + } + ); + + osrf-pycommon = pyFinal.callPackage ./osrf-pycommon { }; rosdep = pyFinal.callPackage ./rosdep { }; diff --git a/pkgs/gazebo/default.nix b/pkgs/gazebo/default.nix index bd911ebf85..79debb1802 100644 --- a/pkgs/gazebo/default.nix +++ b/pkgs/gazebo/default.nix @@ -1,13 +1,44 @@ -{ lib, mkDerivation, fetchpatch, fetchurl, cmake, pkg-config, ronn, libGL -, openal, hdf5, curl, tinyxml, tinyxml-2, libtar, gts, libusb1, qtbase, gdal -, libuuid, graphviz, libsForQt5, freeimage, boost, protobuf, sdformat, tbb -, ogre1_9, ffmpeg, ignition, ignition-cmake ? ignition.cmake0 -, ignition-common ? ignition.common, ignition-math ? ignition.math4 -, ignition-transport ? ignition.transport8, ignition-msgs ? ignition.msgs5 -, ignition-fuel-tools ? ignition.fuel-tools4 -, wrapGAppsHook +{ + lib, + mkDerivation, + fetchpatch, + fetchurl, + cmake, + pkg-config, + ronn, + libGL, + openal, + hdf5, + curl, + tinyxml, + tinyxml-2, + libtar, + gts, + libusb1, + qtbase, + gdal, + libuuid, + graphviz, + libsForQt5, + freeimage, + boost, + protobuf, + sdformat, + tbb, + ogre1_9, + ffmpeg, + ignition, + ignition-cmake ? ignition.cmake0, + ignition-common ? ignition.common, + ignition-math ? ignition.math4, + ignition-transport ? ignition.transport8, + ignition-msgs ? ignition.msgs5, + ignition-fuel-tools ? ignition.fuel-tools4, + wrapGAppsHook, -, bullet, withBulletEngineSupport ? false }: + bullet, + withBulletEngineSupport ? false, +}: mkDerivation rec { pname = "gazebo"; @@ -31,7 +62,12 @@ mkDerivation rec { cmakeFlags = [ "-DUSE_HOST_CFLAGS=False" ]; - nativeBuildInputs = [ cmake pkg-config ronn wrapGAppsHook ]; + nativeBuildInputs = [ + cmake + pkg-config + ronn + wrapGAppsHook + ]; buildInputs = [ libGL diff --git a/pkgs/gazebo/gz-cmake/3.nix b/pkgs/gazebo/gz-cmake/3.nix index a6e642284f..38ee13e21a 100644 --- a/pkgs/gazebo/gz-cmake/3.nix +++ b/pkgs/gazebo/gz-cmake/3.nix @@ -1,6 +1,9 @@ -{ callPackage, ... } @ args : +{ callPackage, ... }@args: -callPackage ./generic.nix ({ - version = "3.0.1"; - srcHash = "sha256-yDQYdui+JtLhBoXHRMvyhAqrnsbOSTx9qfnddYjuH7Q="; -} // args) +callPackage ./generic.nix ( + { + version = "3.0.1"; + srcHash = "sha256-yDQYdui+JtLhBoXHRMvyhAqrnsbOSTx9qfnddYjuH7Q="; + } + // args +) diff --git a/pkgs/gazebo/gz-cmake/generic.nix b/pkgs/gazebo/gz-cmake/generic.nix index df88ec8a2f..d9b520728c 100644 --- a/pkgs/gazebo/gz-cmake/generic.nix +++ b/pkgs/gazebo/gz-cmake/generic.nix @@ -1,6 +1,14 @@ -{ lib, stdenv, fetchFromGitHub, fetchpatch, cmake, pkg-config -, version, srcHash -, ... }: +{ + lib, + stdenv, + fetchFromGitHub, + fetchpatch, + cmake, + pkg-config, + version, + srcHash, + ... +}: stdenv.mkDerivation rec { pname = "gz-cmake${lib.versions.major version}"; diff --git a/pkgs/gazebo/gz-math/7.nix b/pkgs/gazebo/gz-math/7.nix index 3dee27f21a..ec4a7669ff 100644 --- a/pkgs/gazebo/gz-math/7.nix +++ b/pkgs/gazebo/gz-math/7.nix @@ -1,8 +1,16 @@ -{ callPackage, gz-cmake_3, gz-utils_2, ... } @ args: +{ + callPackage, + gz-cmake_3, + gz-utils_2, + ... +}@args: -callPackage ./generic.nix (args // { - version = "7.1.0"; - srcHash = "sha256-iAjafpJJSCZoQfb2D5qctUpyph73ZpVRjnJWHU8zNnQ="; - gz-cmake = gz-cmake_3; - gz-utils = gz-utils_2; -}) +callPackage ./generic.nix ( + args + // { + version = "7.1.0"; + srcHash = "sha256-iAjafpJJSCZoQfb2D5qctUpyph73ZpVRjnJWHU8zNnQ="; + gz-cmake = gz-cmake_3; + gz-utils = gz-utils_2; + } +) diff --git a/pkgs/gazebo/gz-math/generic.nix b/pkgs/gazebo/gz-math/generic.nix index 5511a24bf1..0ebf4bee7d 100644 --- a/pkgs/gazebo/gz-math/generic.nix +++ b/pkgs/gazebo/gz-math/generic.nix @@ -1,6 +1,15 @@ -{ lib, stdenv, fetchFromGitHub, cmake, gz-cmake, gz-utils, eigen -, version, srcHash -, ... }: +{ + lib, + stdenv, + fetchFromGitHub, + cmake, + gz-cmake, + gz-utils, + eigen, + version, + srcHash, + ... +}: stdenv.mkDerivation rec { pname = "gz-math${lib.versions.major version}"; @@ -14,8 +23,14 @@ stdenv.mkDerivation rec { hash = srcHash; }; - nativeBuildInputs = [ cmake gz-cmake ]; - buildInputs = [ gz-utils eigen ]; + nativeBuildInputs = [ + cmake + gz-cmake + ]; + buildInputs = [ + gz-utils + eigen + ]; meta = with lib; { homepage = "https://gazebosim.org/libs/math"; diff --git a/pkgs/gazebo/gz-utils/2.nix b/pkgs/gazebo/gz-utils/2.nix index 32b14d6c4f..2d87f20d16 100644 --- a/pkgs/gazebo/gz-utils/2.nix +++ b/pkgs/gazebo/gz-utils/2.nix @@ -1,7 +1,10 @@ -{ callPackage, gz-cmake_3, ... } @ args: +{ callPackage, gz-cmake_3, ... }@args: -callPackage ./generic.nix (args // { - version = "2.0.0"; - srcHash = "sha256-osY+q+H7F05gcLrpyMGeLsddh2nevG4lZsFeyeZWdaY="; - gz-cmake = gz-cmake_3; -}) +callPackage ./generic.nix ( + args + // { + version = "2.0.0"; + srcHash = "sha256-osY+q+H7F05gcLrpyMGeLsddh2nevG4lZsFeyeZWdaY="; + gz-cmake = gz-cmake_3; + } +) diff --git a/pkgs/gazebo/gz-utils/generic.nix b/pkgs/gazebo/gz-utils/generic.nix index 551eed3297..e51537bf70 100644 --- a/pkgs/gazebo/gz-utils/generic.nix +++ b/pkgs/gazebo/gz-utils/generic.nix @@ -1,6 +1,13 @@ -{ lib, stdenv, fetchFromGitHub, cmake, gz-cmake -, version, srcHash -, ... }: +{ + lib, + stdenv, + fetchFromGitHub, + cmake, + gz-cmake, + version, + srcHash, + ... +}: stdenv.mkDerivation rec { pname = "gz-utils${lib.versions.major version}"; @@ -14,7 +21,10 @@ stdenv.mkDerivation rec { hash = srcHash; }; - nativeBuildInputs = [ cmake gz-cmake ]; + nativeBuildInputs = [ + cmake + gz-cmake + ]; meta = with lib; { homepage = "https://gazebosim.org/libs/utils"; diff --git a/pkgs/geographiclib/default.nix b/pkgs/geographiclib/default.nix index 7cba6c09e4..2a5c8d3b98 100644 --- a/pkgs/geographiclib/default.nix +++ b/pkgs/geographiclib/default.nix @@ -1,11 +1,23 @@ -{ lib, stdenv, fetchurl, cmake }: +{ + lib, + stdenv, + fetchurl, + cmake, +}: let - fetchData = { subdir, file, hash }: fetchurl { - url = "mirror://sourceforge/geographiclib/${subdir}-distrib/${file}.tar.bz2"; - inherit hash; - }; -in stdenv.mkDerivation rec { + fetchData = + { + subdir, + file, + hash, + }: + fetchurl { + url = "mirror://sourceforge/geographiclib/${subdir}-distrib/${file}.tar.bz2"; + inherit hash; + }; +in +stdenv.mkDerivation rec { pname = "geographiclib"; version = "2.1.1"; @@ -24,7 +36,11 @@ in stdenv.mkDerivation rec { ]; data = [ - (fetchData { subdir = "geoids"; file = "egm96-5"; hash = "sha256-xGIk+Pcj3JFdlxefThWAqY1sdC/iuCzY/vDsqq0T5hQ="; }) + (fetchData { + subdir = "geoids"; + file = "egm96-5"; + hash = "sha256-xGIk+Pcj3JFdlxefThWAqY1sdC/iuCzY/vDsqq0T5hQ="; + }) ]; postInstall = '' diff --git a/pkgs/ignition/cmake/0.nix b/pkgs/ignition/cmake/0.nix index 00ff9090b7..060ceb248c 100644 --- a/pkgs/ignition/cmake/0.nix +++ b/pkgs/ignition/cmake/0.nix @@ -1,7 +1,10 @@ -{ callPackage, ... } @ args : +{ callPackage, ... }@args: -callPackage ./. ({ - majorVersion = ""; - version = "0.6.1"; - srcHash = "sha256-DwIzyLC51zQpoqZC2yJ5RMuODkQVSPROOXnUpIccdJE="; -} // args) +callPackage ./. ( + { + majorVersion = ""; + version = "0.6.1"; + srcHash = "sha256-DwIzyLC51zQpoqZC2yJ5RMuODkQVSPROOXnUpIccdJE="; + } + // args +) diff --git a/pkgs/ignition/cmake/default.nix b/pkgs/ignition/cmake/default.nix index 96dee3a595..d70b0cbc4a 100644 --- a/pkgs/ignition/cmake/default.nix +++ b/pkgs/ignition/cmake/default.nix @@ -1,8 +1,15 @@ -{ lib, stdenv, fetchFromGitHub, fetchpatch, cmake, pkg-config -, majorVersion ? "2" -, version ? "2.16.0" -, srcHash ? "sha256-QiExRbIN/CtzB+jOknJokDxyqQGdkZQvVABJumYNCFI=" -, ... }: +{ + lib, + stdenv, + fetchFromGitHub, + fetchpatch, + cmake, + pkg-config, + majorVersion ? "2", + version ? "2.16.0", + srcHash ? "sha256-QiExRbIN/CtzB+jOknJokDxyqQGdkZQvVABJumYNCFI=", + ... +}: stdenv.mkDerivation rec { pname = "ignition-cmake${majorVersion}"; @@ -18,10 +25,14 @@ stdenv.mkDerivation rec { # Fix pkgconfig with absolute CMAKE_INSTALL_*DIR patches = - lib.optional (majorVersion == "" /* 0 */) (fetchpatch { - url = "https://github.com/gazebosim/gz-cmake/commit/fe3100f11073a82a8faf63eb629de9f77fe2b331.patch"; - hash = "sha256-fgSAOZoQmZt/nAx2eBDyC+4+0m++crlZ2BGRH4UcuQY="; - }); + lib.optional + ( + majorVersion == "" # 0 + ) + (fetchpatch { + url = "https://github.com/gazebosim/gz-cmake/commit/fe3100f11073a82a8faf63eb629de9f77fe2b331.patch"; + hash = "sha256-fgSAOZoQmZt/nAx2eBDyC+4+0m++crlZ2BGRH4UcuQY="; + }); nativeBuildInputs = [ cmake ]; # pkg-config is needed to use some CMake modules in this package diff --git a/pkgs/ignition/common/3.nix b/pkgs/ignition/common/3.nix index 5bdd046f51..ed1695b959 100644 --- a/pkgs/ignition/common/3.nix +++ b/pkgs/ignition/common/3.nix @@ -1,7 +1,10 @@ -{ callPackage, ignition, ... } @ args : +{ callPackage, ignition, ... }@args: -callPackage ./. ({ - majorVersion = "3"; - version = "3.16.0"; - srcHash = "sha256-lK3c+aB+46/Pid9vO/gxUh6zicPHf4u2llvwW6KD0Ec="; -} // args) +callPackage ./. ( + { + majorVersion = "3"; + version = "3.16.0"; + srcHash = "sha256-lK3c+aB+46/Pid9vO/gxUh6zicPHf4u2llvwW6KD0Ec="; + } + // args +) diff --git a/pkgs/ignition/common/default.nix b/pkgs/ignition/common/default.nix index bd42d91171..501ba2ceac 100644 --- a/pkgs/ignition/common/default.nix +++ b/pkgs/ignition/common/default.nix @@ -1,10 +1,24 @@ -{ lib, stdenv, fetchFromGitHub, fetchpatch, cmake, pkg-config, ignition -, ignition-cmake ? ignition.cmake, ignition-math ? ignition.math -, ignition-utils ? ignition.utils, libuuid, tinyxml-2, freeimage, gts, ffmpeg -, majorVersion ? "4" -, version ? "4.7.0" -, srcHash ? "sha256-y8qp0UVXxSJm0aJeUD64+aG+gfNEboInW7F6tvHYTPI=" -, ... }: +{ + lib, + stdenv, + fetchFromGitHub, + fetchpatch, + cmake, + pkg-config, + ignition, + ignition-cmake ? ignition.cmake, + ignition-math ? ignition.math, + ignition-utils ? ignition.utils, + libuuid, + tinyxml-2, + freeimage, + gts, + ffmpeg, + majorVersion ? "4", + version ? "4.7.0", + srcHash ? "sha256-y8qp0UVXxSJm0aJeUD64+aG+gfNEboInW7F6tvHYTPI=", + ... +}: stdenv.mkDerivation rec { pname = "ignition-common${majorVersion}"; @@ -28,8 +42,14 @@ stdenv.mkDerivation rec { nativeBuildInputs = [ cmake ]; propagatedNativeBuildInputs = [ ignition-cmake ]; - buildInputs = [ ignition-math tinyxml-2 ignition-math gts freeimage ffmpeg ] - ++ lib.optional (lib.versionAtLeast version "4") ignition-utils; + buildInputs = [ + ignition-math + tinyxml-2 + ignition-math + gts + freeimage + ffmpeg + ] ++ lib.optional (lib.versionAtLeast version "4") ignition-utils; propagatedBuildInputs = [ libuuid ]; meta = with lib; { diff --git a/pkgs/ignition/fuel-tools/4.nix b/pkgs/ignition/fuel-tools/4.nix index 49dbeda8c0..0d33d4fa18 100644 --- a/pkgs/ignition/fuel-tools/4.nix +++ b/pkgs/ignition/fuel-tools/4.nix @@ -1,9 +1,12 @@ -{ callPackage, ignition, ... } @ args : +{ callPackage, ignition, ... }@args: -callPackage ./. ({ - majorVersion = "4"; - version = "4.8.3"; - srcHash = "sha256-Fa/xKb5J37OM0p8HB+Iu1cA47BbPBYZkO4z8XhSB5oc="; - ignition-common = ignition.common3; - ignition-msgs = ignition.msgs5; -} // args) +callPackage ./. ( + { + majorVersion = "4"; + version = "4.8.3"; + srcHash = "sha256-Fa/xKb5J37OM0p8HB+Iu1cA47BbPBYZkO4z8XhSB5oc="; + ignition-common = ignition.common3; + ignition-msgs = ignition.msgs5; + } + // args +) diff --git a/pkgs/ignition/fuel-tools/default.nix b/pkgs/ignition/fuel-tools/default.nix index 68fa4a6d85..9b7930c5c8 100644 --- a/pkgs/ignition/fuel-tools/default.nix +++ b/pkgs/ignition/fuel-tools/default.nix @@ -1,10 +1,22 @@ -{ lib, stdenv, fetchFromGitHub, cmake, ignition -, ignition-cmake ? ignition.cmake, ignition-common ? ignition.common -, ignition-msgs ? ignition.msgs, tinyxml-2, curl, jsoncpp, libyaml, libzip -, majorVersion ? "7" -, version ? "7.2.2" -, srcHash ? "sha256-SgU7OuD6OoSvC2UJyZUFjc6IOMY7tukGGg5Ef5pGCPY=" -, ... }: +{ + lib, + stdenv, + fetchFromGitHub, + cmake, + ignition, + ignition-cmake ? ignition.cmake, + ignition-common ? ignition.common, + ignition-msgs ? ignition.msgs, + tinyxml-2, + curl, + jsoncpp, + libyaml, + libzip, + majorVersion ? "7", + version ? "7.2.2", + srcHash ? "sha256-SgU7OuD6OoSvC2UJyZUFjc6IOMY7tukGGg5Ef5pGCPY=", + ... +}: stdenv.mkDerivation rec { pname = "ignition-fuel-tools${majorVersion}"; diff --git a/pkgs/ignition/math/4.nix b/pkgs/ignition/math/4.nix index d46f369301..ba0be5413a 100644 --- a/pkgs/ignition/math/4.nix +++ b/pkgs/ignition/math/4.nix @@ -1,8 +1,11 @@ -{ callPackage, ignition, ... } @ args : +{ callPackage, ignition, ... }@args: -callPackage ./. ({ - majorVersion = "4"; - version = "4.0.0"; - srcHash = "sha256-GDydOD/n8Ip6cVCBsLhgzweCgRVQjJCwVqIbV1lvfKM="; - ignition-cmake = ignition.cmake0; -} // args) +callPackage ./. ( + { + majorVersion = "4"; + version = "4.0.0"; + srcHash = "sha256-GDydOD/n8Ip6cVCBsLhgzweCgRVQjJCwVqIbV1lvfKM="; + ignition-cmake = ignition.cmake0; + } + // args +) diff --git a/pkgs/ignition/math/default.nix b/pkgs/ignition/math/default.nix index 05d35eabff..df7e9e7fc9 100644 --- a/pkgs/ignition/math/default.nix +++ b/pkgs/ignition/math/default.nix @@ -1,8 +1,15 @@ -{ lib, stdenv, fetchFromGitHub, cmake, ignition, ignition-cmake ? ignition.cmake -, majorVersion ? "6" -, version ? "6.13.0" -, srcHash ? "sha256-4kWbHdsDCCEgXHy3Dv4oZKdVBY4eJLKovYu+HUgkSjE=" -, ... }: +{ + lib, + stdenv, + fetchFromGitHub, + cmake, + ignition, + ignition-cmake ? ignition.cmake, + majorVersion ? "6", + version ? "6.13.0", + srcHash ? "sha256-4kWbHdsDCCEgXHy3Dv4oZKdVBY4eJLKovYu+HUgkSjE=", + ... +}: stdenv.mkDerivation rec { pname = "ignition-math${majorVersion}"; diff --git a/pkgs/ignition/msgs/5.nix b/pkgs/ignition/msgs/5.nix index fc6ad30746..bffc590e02 100644 --- a/pkgs/ignition/msgs/5.nix +++ b/pkgs/ignition/msgs/5.nix @@ -1,7 +1,10 @@ -{ callPackage, ignition, ... } @ args : +{ callPackage, ignition, ... }@args: -callPackage ./. ({ - majorVersion = "5"; - version = "5.11.0"; - srcHash = "sha256-i2n8x6ubf7ibujfC8v8BcKyPRQTzLoyWMGoOEoKTBys="; -} // args) +callPackage ./. ( + { + majorVersion = "5"; + version = "5.11.0"; + srcHash = "sha256-i2n8x6ubf7ibujfC8v8BcKyPRQTzLoyWMGoOEoKTBys="; + } + // args +) diff --git a/pkgs/ignition/msgs/default.nix b/pkgs/ignition/msgs/default.nix index 2800902ece..32c270bf1b 100644 --- a/pkgs/ignition/msgs/default.nix +++ b/pkgs/ignition/msgs/default.nix @@ -1,9 +1,19 @@ -{ lib, stdenv, fetchFromGitHub, fetchpatch, cmake, tinyxml-2, ignition -, ignition-cmake ? ignition.cmake, protobuf, ignition-math ? ignition.math -, majorVersion ? "8" -, version ? "8.7.0" -, srcHash ? "sha256-hG4UJfcq6DsyMqTWIcUQ15UCQNfdzTzwvJBpR9kmu84=" -, ... }: +{ + lib, + stdenv, + fetchFromGitHub, + fetchpatch, + cmake, + tinyxml-2, + ignition, + ignition-cmake ? ignition.cmake, + protobuf, + ignition-math ? ignition.math, + majorVersion ? "8", + version ? "8.7.0", + srcHash ? "sha256-hG4UJfcq6DsyMqTWIcUQ15UCQNfdzTzwvJBpR9kmu84=", + ... +}: stdenv.mkDerivation rec { pname = "ignition-msgs${majorVersion}"; @@ -18,14 +28,20 @@ stdenv.mkDerivation rec { }; # Don't require Protobuf 3 - patches = [ (fetchpatch { - url = "https://github.com/gazebosim/gz-msgs/commit/0c0926c37042ac8f5aeb49ac36101acd3e084c6b.patch"; - hash = "sha256-QnR1WtB4gbgyJKbQ4doMhfSjJBksEeQ3Us4y9KqCWeY="; - }) ]; + patches = [ + (fetchpatch { + url = "https://github.com/gazebosim/gz-msgs/commit/0c0926c37042ac8f5aeb49ac36101acd3e084c6b.patch"; + hash = "sha256-QnR1WtB4gbgyJKbQ4doMhfSjJBksEeQ3Us4y9KqCWeY="; + }) + ]; nativeBuildInputs = [ cmake ]; propagatedNativeBuildInputs = [ ignition-cmake ]; - propagatedBuildInputs = [ protobuf ignition-math tinyxml-2 ]; + propagatedBuildInputs = [ + protobuf + ignition-math + tinyxml-2 + ]; meta = with lib; { homepage = "https://ignitionrobotics.org/libs/msgs"; diff --git a/pkgs/ignition/tools/default.nix b/pkgs/ignition/tools/default.nix index 494f03bbd8..ac4708dd1b 100644 --- a/pkgs/ignition/tools/default.nix +++ b/pkgs/ignition/tools/default.nix @@ -1,4 +1,10 @@ -{ lib, stdenv, fetchFromGitHub, cmake, ruby }: +{ + lib, + stdenv, + fetchFromGitHub, + cmake, + ruby, +}: stdenv.mkDerivation rec { pname = "ignition-tools"; @@ -12,7 +18,10 @@ stdenv.mkDerivation rec { sha256 = "sha256-HgYT7MARRnOdUuUllxRn9pl7tsWO5RDIFDObzJQgZpc="; }; - nativeBuildInputs = [ cmake ruby ]; + nativeBuildInputs = [ + cmake + ruby + ]; meta = with lib; { homepage = "https://bitbucket.org/ignitionrobotics/ign-tools"; diff --git a/pkgs/ignition/transport/8.nix b/pkgs/ignition/transport/8.nix index 3fa8ab7602..ca02a75519 100644 --- a/pkgs/ignition/transport/8.nix +++ b/pkgs/ignition/transport/8.nix @@ -1,8 +1,11 @@ -{ callPackage, ignition, ... } @ args : +{ callPackage, ignition, ... }@args: -callPackage ./. ({ - majorVersion = "8"; - version = "8.4.0"; - srcHash = "sha256-ca11gJkGzK8AiFQc+0F98968yrnvzS4lHjWYA/JF5g8="; - ignition-msgs = ignition.msgs5; -} // args) +callPackage ./. ( + { + majorVersion = "8"; + version = "8.4.0"; + srcHash = "sha256-ca11gJkGzK8AiFQc+0F98968yrnvzS4lHjWYA/JF5g8="; + ignition-msgs = ignition.msgs5; + } + // args +) diff --git a/pkgs/ignition/transport/default.nix b/pkgs/ignition/transport/default.nix index f1be37fc43..8bcfdde802 100644 --- a/pkgs/ignition/transport/default.nix +++ b/pkgs/ignition/transport/default.nix @@ -1,11 +1,25 @@ -{ lib, stdenv, fetchFromGitHub, fetchpatch, cmake, ignition -, ignition-cmake ? ignition.cmake, ignition-math ? ignition.math -, ignition-msgs ? ignition.msgs, ignition-utils ? ignition.utils, protobuf -, libuuid, sqlite, libsodium, cppzmq, zeromq -, majorVersion ? "11" -, version ? "11.4.1" -, srcHash ? "sha256-wQ/ugKYopWgSaa6tqPrp8oQexPpnA6fa28L383OGNXM=" -, ... }: +{ + lib, + stdenv, + fetchFromGitHub, + fetchpatch, + cmake, + ignition, + ignition-cmake ? ignition.cmake, + ignition-math ? ignition.math, + ignition-msgs ? ignition.msgs, + ignition-utils ? ignition.utils, + protobuf, + libuuid, + sqlite, + libsodium, + cppzmq, + zeromq, + majorVersion ? "11", + version ? "11.4.1", + srcHash ? "sha256-wQ/ugKYopWgSaa6tqPrp8oQexPpnA6fa28L383OGNXM=", + ... +}: stdenv.mkDerivation rec { pname = "ignition-transport${majorVersion}"; @@ -28,8 +42,19 @@ stdenv.mkDerivation rec { nativeBuildInputs = [ cmake ]; propagatedNativeBuildInputs = [ ignition-cmake ]; - buildInputs = [ ignition-math sqlite libsodium ignition-utils ]; - propagatedBuildInputs = [ protobuf cppzmq zeromq libuuid ignition-msgs ]; + buildInputs = [ + ignition-math + sqlite + libsodium + ignition-utils + ]; + propagatedBuildInputs = [ + protobuf + cppzmq + zeromq + libuuid + ignition-msgs + ]; meta = with lib; { homepage = "https://ignitionrobotics.org/libs/transport"; diff --git a/pkgs/ignition/utils/default.nix b/pkgs/ignition/utils/default.nix index 7d32c452b3..024dc475f0 100644 --- a/pkgs/ignition/utils/default.nix +++ b/pkgs/ignition/utils/default.nix @@ -1,9 +1,15 @@ -{ lib, stdenv, fetchFromGitHub, cmake, ignition -, ignition-cmake ? ignition.cmake -, majorVersion ? "1" -, version ? "1.5.1" -, srcHash ? "sha256-Ymlw1SBoSlHwxe/4E3jdMy8ECCFNy8YGboqTQi6UIs4=" -, ... }: +{ + lib, + stdenv, + fetchFromGitHub, + cmake, + ignition, + ignition-cmake ? ignition.cmake, + majorVersion ? "1", + version ? "1.5.1", + srcHash ? "sha256-Ymlw1SBoSlHwxe/4E3jdMy8ECCFNy8YGboqTQi6UIs4=", + ... +}: stdenv.mkDerivation rec { pname = "ignition-utils${majorVersion}"; @@ -17,7 +23,10 @@ stdenv.mkDerivation rec { hash = srcHash; }; - nativeBuildInputs = [ cmake ignition-cmake ]; + nativeBuildInputs = [ + cmake + ignition-cmake + ]; meta = with lib; { homepage = "https://ignitionrobotics.org/libs/common"; diff --git a/pkgs/ogre/1.9.nix b/pkgs/ogre/1.9.nix index a74f91bd3a..729b78b984 100644 --- a/pkgs/ogre/1.9.nix +++ b/pkgs/ogre/1.9.nix @@ -1,30 +1,31 @@ -{ fetchFromGitHub -, stdenv -, lib -, cmake -, libGLU -, libGL -, freetype -, freeimage -, zziplib -, xorgproto -, libXrandr -, libXaw -, freeglut -, libXt -, libpng -, boost -, ois -, libX11 -, libXmu -, libSM -, pkg-config -, libXxf86vm -, libICE -, libXrender -, withNvidiaCg ? false -, nvidia_cg_toolkit -, withSamples ? false +{ + fetchFromGitHub, + stdenv, + lib, + cmake, + libGLU, + libGL, + freetype, + freeimage, + zziplib, + xorgproto, + libXrandr, + libXaw, + freeglut, + libXt, + libpng, + boost, + ois, + libX11, + libXmu, + libSM, + pkg-config, + libXxf86vm, + libICE, + libXrender, + withNvidiaCg ? false, + nvidia_cg_toolkit, + withSamples ? false, }: stdenv.mkDerivation rec { @@ -46,41 +47,51 @@ stdenv.mkDerivation rec { --replace-fail '#include ' "" ''; - cmakeFlags = [ - "-DOGRE_BUILD_SAMPLES=${toString withSamples}" - ] - ++ map (x: "-DOGRE_BUILD_PLUGIN_${x}=on") - ([ "BSP" "OCTREE" "PCZ" "PFX" ] ++ lib.optional withNvidiaCg "CG") - ++ map (x: "-DOGRE_BUILD_RENDERSYSTEM_${x}=on") [ "GL" ]; + cmakeFlags = + [ + "-DOGRE_BUILD_SAMPLES=${toString withSamples}" + ] + ++ map (x: "-DOGRE_BUILD_PLUGIN_${x}=on") ( + [ + "BSP" + "OCTREE" + "PCZ" + "PFX" + ] + ++ lib.optional withNvidiaCg "CG" + ) + ++ map (x: "-DOGRE_BUILD_RENDERSYSTEM_${x}=on") [ "GL" ]; nativeBuildInputs = [ cmake pkg-config ]; - buildInputs = [ - libGLU - libGL - freetype - freeimage - zziplib - xorgproto - libXrandr - libXaw - freeglut - libXt - libpng - boost - ois - libX11 - libXmu - libSM - libXxf86vm - libICE - libXrender - ] ++ lib.optionals withNvidiaCg [ - nvidia_cg_toolkit - ]; + buildInputs = + [ + libGLU + libGL + freetype + freeimage + zziplib + xorgproto + libXrandr + libXaw + freeglut + libXt + libpng + boost + ois + libX11 + libXmu + libSM + libXxf86vm + libICE + libXrender + ] + ++ lib.optionals withNvidiaCg [ + nvidia_cg_toolkit + ]; meta = with lib; { description = "3D Object-Oriented Graphics Rendering Engine"; diff --git a/pkgs/openni2/default.nix b/pkgs/openni2/default.nix index 2e0395845a..b7f2eebcba 100644 --- a/pkgs/openni2/default.nix +++ b/pkgs/openni2/default.nix @@ -1,12 +1,26 @@ -{ lib, clangStdenv, fetchurl, fetchFromGitHub, fetchDebianPatch, libusb1, jdk -, python3, doxygen, libGLU, xorg, freeglut, libjpeg }: +{ + lib, + clangStdenv, + fetchurl, + fetchFromGitHub, + fetchDebianPatch, + libusb1, + jdk, + python3, + doxygen, + libGLU, + xorg, + freeglut, + libjpeg, +}: let libopenni2_pc = fetchurl { url = "https://salsa.debian.org/multimedia-team/openni2/raw/8491921c14b8c41850f0e0b0493e195cb53a71a3/debian/libopenni2.pc"; sha256 = "1023s3j71m56fnvqmai4683ds4fbm92dhf1s8csdrdn88a726ygm"; }; -in clangStdenv.mkDerivation rec { +in +clangStdenv.mkDerivation rec { pname = "openni2"; version = "2.2.0.33"; @@ -32,10 +46,23 @@ in clangStdenv.mkDerivation rec { }) ]; - nativeBuildInputs = [ jdk python3 doxygen ]; - buildInputs = [ libusb1 libGLU xorg.libX11 freeglut libjpeg ]; + nativeBuildInputs = [ + jdk + python3 + doxygen + ]; + buildInputs = [ + libusb1 + libGLU + xorg.libX11 + freeglut + libjpeg + ]; - outputs = [ "out" "doc" ]; + outputs = [ + "out" + "doc" + ]; postPatch = '' patchShebangs Source @@ -52,7 +79,10 @@ in clangStdenv.mkDerivation rec { --replace-fail 'register ' "" ''; - makeFlags = [ "CFG=Release" "ALLOW_WARNINGS=1" ]; + makeFlags = [ + "CFG=Release" + "ALLOW_WARNINGS=1" + ]; postBuild = '' make doc diff --git a/pkgs/opensplice/default.nix b/pkgs/opensplice/default.nix index 9b98478e8b..591c22b01e 100644 --- a/pkgs/opensplice/default.nix +++ b/pkgs/opensplice/default.nix @@ -1,20 +1,30 @@ -{ stdenv, lib, fetchFromGitHub, perl, bison, flex }: +{ + stdenv, + lib, + fetchFromGitHub, + perl, + bison, + flex, +}: let - target = { - "armv6l-linux" = "armv6l.linux"; - "armv7l-linux" = "armv7l.linux"; - "aarch64-linux" = "armv8.linux"; - "x86_64-linux" = "x86_64.linux"; - }.${stdenv.hostPlatform.system} or (throw "Unsupported platform"); -in stdenv.mkDerivation rec { + target = + { + "armv6l-linux" = "armv6l.linux"; + "armv7l-linux" = "armv7l.linux"; + "aarch64-linux" = "armv8.linux"; + "x86_64-linux" = "x86_64.linux"; + } + .${stdenv.hostPlatform.system} or (throw "Unsupported platform"); +in +stdenv.mkDerivation rec { pname = "opensplice"; version = "6.9.210323"; src = fetchFromGitHub { owner = "ADLINK-IST"; repo = pname; - rev = "OSPL_V${lib.replaceStrings ["."] ["_"] version}OSS_RELEASE"; + rev = "OSPL_V${lib.replaceStrings [ "." ] [ "_" ] version}OSS_RELEASE"; sha256 = "0zg1gcrxkgp20yd7dil30qrm6w58jvn9x106rvsfs8q1vaafg5f7"; }; @@ -26,14 +36,18 @@ in stdenv.mkDerivation rec { sed -i "s#/usr/bin/ar#$AR#" setup/*-default.mak ''; - nativeBuildInputs = [ perl bison flex ]; + nativeBuildInputs = [ + perl + bison + flex + ]; configurePhase = '' runHook preConfigure . configure ${target}-release runHook postConfigure ''; - + postInstall = '' cp -aT 'install/RTS/${target}' "$out" ''; @@ -50,6 +64,11 @@ in stdenv.mkDerivation rec { ''; license = licenses.asl20; maintainers = with maintainers; [ lopsided98 ]; - platforms = [ "armv6l-linux" "armv7l-linux" "aarch64-linux" "x86_64-linux" ]; + platforms = [ + "armv6l-linux" + "armv7l-linux" + "aarch64-linux" + "x86_64-linux" + ]; }; } diff --git a/pkgs/osrf-pycommon/default.nix b/pkgs/osrf-pycommon/default.nix index 2a4219fcfe..c9f8cf75b1 100644 --- a/pkgs/osrf-pycommon/default.nix +++ b/pkgs/osrf-pycommon/default.nix @@ -1,4 +1,8 @@ -{ lib, buildPythonPackage, fetchPypi }: +{ + lib, + buildPythonPackage, + fetchPypi, +}: buildPythonPackage rec { pname = "osrf_pycommon"; diff --git a/pkgs/rosdep/default.nix b/pkgs/rosdep/default.nix index 7556c816af..81997e3c2f 100644 --- a/pkgs/rosdep/default.nix +++ b/pkgs/rosdep/default.nix @@ -1,5 +1,13 @@ -{ lib, buildPythonPackage, fetchPypi, pyyaml, setuptools, catkin-pkg, rospkg -, rosdistro }: +{ + lib, + buildPythonPackage, + fetchPypi, + pyyaml, + setuptools, + catkin-pkg, + rospkg, + rosdistro, +}: buildPythonPackage rec { pname = "rosdep"; @@ -13,7 +21,13 @@ buildPythonPackage rec { # Tries to download files doCheck = false; - propagatedBuildInputs = [ pyyaml setuptools catkin-pkg rospkg rosdistro ]; + propagatedBuildInputs = [ + pyyaml + setuptools + catkin-pkg + rospkg + rosdistro + ]; meta = with lib; { description = "Package manager abstraction tool for ROS"; diff --git a/pkgs/rosdistro/default.nix b/pkgs/rosdistro/default.nix index 5ca157184d..cf3d2dbeaa 100644 --- a/pkgs/rosdistro/default.nix +++ b/pkgs/rosdistro/default.nix @@ -1,4 +1,12 @@ -{ lib, buildPythonPackage, fetchPypi, pyyaml, setuptools, catkin-pkg, rospkg }: +{ + lib, + buildPythonPackage, + fetchPypi, + pyyaml, + setuptools, + catkin-pkg, + rospkg, +}: buildPythonPackage rec { pname = "rosdistro"; @@ -9,7 +17,12 @@ buildPythonPackage rec { hash = "sha256-RwOCS1hwS8oZBhMuO9PUK6cq9zhh7QPVoZJUeKcr+ys="; }; - propagatedBuildInputs = [ pyyaml setuptools catkin-pkg rospkg ]; + propagatedBuildInputs = [ + pyyaml + setuptools + catkin-pkg + rospkg + ]; meta = with lib; { description = "A tool to work with rosdistro files"; diff --git a/pkgs/rosidl-generator-rs/default.nix b/pkgs/rosidl-generator-rs/default.nix index 06444a8c10..3e37aa5a8b 100644 --- a/pkgs/rosidl-generator-rs/default.nix +++ b/pkgs/rosidl-generator-rs/default.nix @@ -1,7 +1,20 @@ -{ lib, buildRosPackage, fetchFromGitHub, fetchpatch, cmake, ament-cmake-core -, ament-cmake-python, rosidl-typesupport-introspection-c, rmw, rosidl-cmake -, rosidl-generator-c, rosidl-parser, rosidl-runtime-c, rosidl-typesupport-c -, rosidl-typesupport-interface }: +{ + lib, + buildRosPackage, + fetchFromGitHub, + fetchpatch, + cmake, + ament-cmake-core, + ament-cmake-python, + rosidl-typesupport-introspection-c, + rmw, + rosidl-cmake, + rosidl-generator-c, + rosidl-parser, + rosidl-runtime-c, + rosidl-typesupport-c, + rosidl-typesupport-interface, +}: buildRosPackage rec { pname = "rosidl-generator-rs"; version = "0.4.1"; @@ -19,11 +32,18 @@ buildRosPackage rec { strictDeps = true; nativeBuildInputs = [ cmake ]; buildInputs = [ - ament-cmake-core ament-cmake-python rosidl-typesupport-introspection-c + ament-cmake-core + ament-cmake-python + rosidl-typesupport-introspection-c ]; propagatedBuildInputs = [ - rmw rosidl-cmake rosidl-generator-c rosidl-parser rosidl-runtime-c - rosidl-typesupport-c rosidl-typesupport-interface + rmw + rosidl-cmake + rosidl-generator-c + rosidl-parser + rosidl-runtime-c + rosidl-typesupport-c + rosidl-typesupport-interface ]; meta = { diff --git a/pkgs/rosinstall-generator/default.nix b/pkgs/rosinstall-generator/default.nix index 2b2a8c11c7..f4d0edcd05 100644 --- a/pkgs/rosinstall-generator/default.nix +++ b/pkgs/rosinstall-generator/default.nix @@ -1,5 +1,15 @@ -{ lib, buildPythonPackage, fetchFromGitHub, fetchpatch, catkin-pkg, rosdistro -, rospkg, pyyaml, distutils, pytestCheckHook }: +{ + lib, + buildPythonPackage, + fetchFromGitHub, + fetchpatch, + catkin-pkg, + rosdistro, + rospkg, + pyyaml, + distutils, + pytestCheckHook, +}: buildPythonPackage rec { pname = "rosinstall_generator"; @@ -14,7 +24,12 @@ buildPythonPackage rec { nativeBuildInputs = [ distutils ]; - propagatedBuildInputs = [ catkin-pkg rosdistro rospkg pyyaml ]; + propagatedBuildInputs = [ + catkin-pkg + rosdistro + rospkg + pyyaml + ]; checkInputs = [ pytestCheckHook ]; diff --git a/pkgs/rospkg/default.nix b/pkgs/rospkg/default.nix index 595a5f4372..dd4920e053 100644 --- a/pkgs/rospkg/default.nix +++ b/pkgs/rospkg/default.nix @@ -1,4 +1,11 @@ -{ lib, buildPythonPackage, fetchPypi, catkin-pkg, pyyaml, distro }: +{ + lib, + buildPythonPackage, + fetchPypi, + catkin-pkg, + pyyaml, + distro, +}: buildPythonPackage rec { pname = "rospkg"; @@ -9,7 +16,11 @@ buildPythonPackage rec { hash = "sha256-/OdqdHd4bDcymBJiGY6iUPCX+I4NMynBDBEGm/QMpgQ="; }; - propagatedBuildInputs = [ catkin-pkg pyyaml distro ]; + propagatedBuildInputs = [ + catkin-pkg + pyyaml + distro + ]; setupHook = ./setup-hook.sh; diff --git a/pkgs/sdformat/13.nix b/pkgs/sdformat/13.nix index 3a9aa55f9b..985adb8654 100644 --- a/pkgs/sdformat/13.nix +++ b/pkgs/sdformat/13.nix @@ -1,10 +1,18 @@ -{ callPackage, gz-cmake_3, gz-math_7, gz-utils_2, ... } @ args: - -callPackage ./generic.nix (args // { - version = "13.4.1"; - srcHash = "sha256-BlYXDccIs1kOj34Nwpuemzt1z8aSzZtD8zeWrIQTJHw="; - gz-cmake = gz-cmake_3; - gz-math = gz-math_7; - gz-utils = gz-utils_2; -}) +{ + callPackage, + gz-cmake_3, + gz-math_7, + gz-utils_2, + ... +}@args: +callPackage ./generic.nix ( + args + // { + version = "13.4.1"; + srcHash = "sha256-BlYXDccIs1kOj34Nwpuemzt1z8aSzZtD8zeWrIQTJHw="; + gz-cmake = gz-cmake_3; + gz-math = gz-math_7; + gz-utils = gz-utils_2; + } +) diff --git a/pkgs/sdformat/9.nix b/pkgs/sdformat/9.nix index 8ee15a2fe8..c3549bde2c 100644 --- a/pkgs/sdformat/9.nix +++ b/pkgs/sdformat/9.nix @@ -1,10 +1,12 @@ -{ callPackage, ignition, ... } @ args: - -callPackage ./generic.nix (args // { - version = "9.10.1"; - srcHash = "sha256-C2r5lVqUoisHfrkV8rYbNfVZY8EtDxrstfvltRNHpQ0="; - gz-cmake = ignition.cmake2; - gz-math = ignition.math6; - gz-utils = null; -}) +{ callPackage, ignition, ... }@args: +callPackage ./generic.nix ( + args + // { + version = "9.10.1"; + srcHash = "sha256-C2r5lVqUoisHfrkV8rYbNfVZY8EtDxrstfvltRNHpQ0="; + gz-cmake = ignition.cmake2; + gz-math = ignition.math6; + gz-utils = null; + } +) diff --git a/pkgs/sdformat/generic.nix b/pkgs/sdformat/generic.nix index 398f29ac60..1322816185 100644 --- a/pkgs/sdformat/generic.nix +++ b/pkgs/sdformat/generic.nix @@ -1,23 +1,45 @@ -{ lib, stdenv, fetchurl, fetchpatch, cmake, gz-cmake, ruby -, gz-math, gz-utils, tinyxml-2, tinyxml, urdfdom -, version, srcHash -, ... }: +{ + lib, + stdenv, + fetchurl, + fetchpatch, + cmake, + gz-cmake, + ruby, + gz-math, + gz-utils, + tinyxml-2, + tinyxml, + urdfdom, + version, + srcHash, + ... +}: stdenv.mkDerivation rec { pname = "sdformat"; inherit version; - src = fetchurl { + src = fetchurl { url = "https://osrf-distributions.s3.amazonaws.com/${pname}/releases/${pname}-${version}.tar.bz2"; hash = srcHash; }; enableParallelBuilding = true; - nativeBuildInputs = [ cmake gz-cmake ruby ]; - buildInputs = [ gz-math gz-utils urdfdom ]; - propagatedBuildInputs = [ gz-math ] - ++ lib.singleton (if lib.versionAtLeast version "10.0.0" then tinyxml-2 else tinyxml); + nativeBuildInputs = [ + cmake + gz-cmake + ruby + ]; + buildInputs = [ + gz-math + gz-utils + urdfdom + ]; + propagatedBuildInputs = [ + gz-math + ] ++ lib.singleton (if lib.versionAtLeast version "10.0.0" then tinyxml-2 else tinyxml); meta = with lib; { homepage = "http://sdformat.org/"; diff --git a/pkgs/superflore/default.nix b/pkgs/superflore/default.nix index 876e7f17c9..86a887881b 100644 --- a/pkgs/superflore/default.nix +++ b/pkgs/superflore/default.nix @@ -1,6 +1,20 @@ -{ lib, buildPythonPackage, fetchFromGitHub, xmltodict, termcolor, setuptools -, rosinstall-generator, rosdistro, rosdep, GitPython, requests, docker, pyyaml -, PyGithub, catkin-pkg, rospkg +{ + lib, + buildPythonPackage, + fetchFromGitHub, + xmltodict, + termcolor, + setuptools, + rosinstall-generator, + rosdistro, + rosdep, + GitPython, + requests, + docker, + pyyaml, + PyGithub, + catkin-pkg, + rospkg, }: buildPythonPackage rec { diff --git a/release.nix b/release.nix index b15eafcae2..87f3557cd1 100644 --- a/release.nix +++ b/release.nix @@ -14,24 +14,33 @@ in let pkgs = import nix-ros-overlay { inherit nixpkgs system; }; inherit (pkgs.lib) isDerivation filterAttrs; - inherit (builtins) mapAttrs attrNames filter listToAttrs readDir; - cleanupDistro = (_: a: removeAttrs a [ - "lib" - "python" - "python3" - "python2" - "pythonPackages" - "python2Packages" - "python3Packages" - "boost" - ]); + inherit (builtins) + mapAttrs + attrNames + filter + listToAttrs + readDir + ; + cleanupDistro = ( + _: a: + removeAttrs a [ + "lib" + "python" + "python3" + "python2" + "pythonPackages" + "python2Packages" + "python3Packages" + "boost" + ] + ); releaseRosPackages = mapAttrs cleanupDistro pkgs.rosPackages; overlayAttrNames = attrNames ((import ./overlay.nix) null pkgs); - toplevelPackagesEntries = - map (name: { inherit name; value = pkgs.${name} or null; }) - overlayAttrNames; - validToplevelPackageEntries = filter (e: isDerivation e.value) - toplevelPackagesEntries; + toplevelPackagesEntries = map (name: { + inherit name; + value = pkgs.${name} or null; + }) overlayAttrNames; + validToplevelPackageEntries = filter (e: isDerivation e.value) toplevelPackagesEntries; toplevelPackages = listToAttrs validToplevelPackageEntries; releasePackages = toplevelPackages // { rosPackages = removeAttrs releaseRosPackages [ @@ -39,13 +48,16 @@ let "mkRosDistroOverlay" "foxy" # No CI for EOL distro ]; - examples = mapAttrs - (file: _: import (./examples + "/${file}") { inherit pkgs; }) - (filterAttrs (n: v: v == "regular") - (readDir ./examples)); + examples = mapAttrs (file: _: import (./examples + "/${file}") { inherit pkgs; }) ( + filterAttrs (n: v: v == "regular") (readDir ./examples) + ); }; in -if distro == ".top" then toplevelPackages -else if distro == ".examples" then releasePackages.examples -else if distro == null then releasePackages -else releasePackages.rosPackages.${distro} +if distro == ".top" then + toplevelPackages +else if distro == ".examples" then + releasePackages.examples +else if distro == null then + releasePackages +else + releasePackages.rosPackages.${distro}