diff --git a/README.md b/README.md index c5558d2..b97b286 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,11 @@ reasonably well. usage: ros2nix [-h] [--output OUTPUT | --output-as-ros-pkg-name | --output-as-nix-pkg-name] [--output-dir OUTPUT_DIR] [--fetch] [--distro DISTRO] - [--src-param SRC_PARAM] [--source-root SOURCE_ROOT] [--flake] + [--src-param SRC_PARAM] [--source-root SOURCE_ROOT] + [--extra-build-inputs DEP1,DEP2,...] + [--extra-propagated-build-inputs DEP1,DEP2,...] + [--extra-check-inputs DEP1,DEP2,...] + [--extra-native-build-inputs DEP1,DEP2,...] [--flake] [--nixfmt] [--copyright-holder COPYRIGHT_HOLDER] [--license LICENSE] source [source ...] @@ -53,9 +57,21 @@ options: Set sourceRoot attribute value in the generated Nix expression. Substring '{package_name}' gets replaced with the package name. (default: None) + --extra-build-inputs DEP1,DEP2,... + Additional dependencies to add to the generated Nix + expressions (default: []) + --extra-propagated-build-inputs DEP1,DEP2,... + Additional dependencies to add to the generated Nix + expressions (default: []) + --extra-check-inputs DEP1,DEP2,... + Additional dependencies to add to the generated Nix + expressions (default: []) + --extra-native-build-inputs DEP1,DEP2,... + Additional dependencies to add to the generated Nix + expressions (default: []) --flake Generate top-level flake.nix instead of default.nix. Use with --fetch if some package.xml files are outside - of the flake repo. (default: False) + of the flake repo (default: False) --nixfmt Format the resulting expressions with nixfmt (default: False) --copyright-holder COPYRIGHT_HOLDER diff --git a/ros2nix/ros2nix.py b/ros2nix/ros2nix.py index 324448b..8592b23 100755 --- a/ros2nix/ros2nix.py +++ b/ros2nix/ros2nix.py @@ -150,6 +150,10 @@ def generate_flake(args): ''') +def comma_separated(arg: str) -> list[str]: + return [i.strip() for i in arg.split(",")] + + def ros2nix(args): parser = argparse.ArgumentParser( prog="ros2nix", formatter_class=argparse.ArgumentDefaultsHelpFormatter @@ -200,11 +204,28 @@ def ros2nix(args): "Substring '{package_name}' gets replaced with the package name.", ) + parser.add_argument( + "--extra-build-inputs", type=comma_separated, metavar="DEP1,DEP2,...", default=[], + help="Additional dependencies to add to the generated Nix expressions", + ) + parser.add_argument( + "--extra-propagated-build-inputs", type=comma_separated, metavar="DEP1,DEP2,...", default=[], + help="Additional dependencies to add to the generated Nix expressions", + ) + parser.add_argument( + "--extra-check-inputs", type=comma_separated, metavar="DEP1,DEP2,...", default=[], + help="Additional dependencies to add to the generated Nix expressions", + ) + parser.add_argument( + "--extra-native-build-inputs", type=comma_separated, metavar="DEP1,DEP2,...", default=[], + help="Additional dependencies to add to the generated Nix expressions", + ) + parser.add_argument( "--flake", action="store_true", help="Generate top-level flake.nix instead of default.nix. " - "Use with --fetch if some package.xml files are outside of the flake repo.", + "Use with --fetch if some package.xml files are outside of the flake repo", ) parser.add_argument( "--nixfmt", @@ -326,10 +347,10 @@ def ros2nix(args): licenses=map(NixLicense, pkg.licenses), distro_name=args.distro, build_type=pkg.get_build_type(), - build_inputs=build_inputs, - propagated_build_inputs=propagated_build_inputs, - check_inputs=check_inputs, - native_build_inputs=native_build_inputs, + build_inputs=build_inputs | set(args.extra_build_inputs), + propagated_build_inputs=propagated_build_inputs | set(args.extra_propagated_build_inputs), + check_inputs=check_inputs | set(args.extra_check_inputs), + native_build_inputs=native_build_inputs | set(args.extra_native_build_inputs), **kwargs, )