diff --git a/flake.nix b/flake.nix index da7c8ed..8193695 100644 --- a/flake.nix +++ b/flake.nix @@ -24,6 +24,7 @@ (import ./overlay.nix) gazebo-overlay.overlays.default ]; + config.allowUnfree = true; }; ros = import ros-nixpkgs { inherit system; overlays = [ ros-overlay.overlays.default @@ -34,41 +35,51 @@ rlib = import ./. { inherit pkgs; - inherit (pkgs) lib mayo rbs-workbench cad-gen cg-gen; + inherit (pkgs) lib rbs-workbench cad-gen cg-gen; inherit (pkgs.stdenv) mkDerivation; inherit (pkgs.libsForQt5) wrapQtAppsHook; }; packages = { - inherit (pkgs) cad-gen cg-gen blender; + inherit (pkgs) cad-gen cg-gen blender cad-gen-docker; }; inherit ros pkgs; devShells = { default = - let - my-python-packages = p: with p; [ - unified-planning - pybullet - scipy - spatialmath - rcg-pipeline - rbs-workbench - ]; - in - pkgs.mkShell { - packages = (with pkgs; [ freecad mayo ]) ++ [ (pkgs.python3.withPackages my-python-packages) ]; - }; + let + my-python-packages = p: with p; [ + unified-planning + pybullet + scipy + spatialmath + rcg-pipeline + rbs-workbench + ]; + in + pkgs.mkShell { + packages = (with pkgs; [ freecad ]) ++ [ (pkgs.python3.withPackages my-python-packages) ]; + }; + + test = + let + my-python-packages = p: with p; [ scenario ]; + in + pkgs.mkShell { + packages = [ (pkgs.python3.withPackages my-python-packages) ]; + }; ros = pkgs.mkShell { name = "ROS environment"; packages = [ + pkgs.vcstool ros.colcon (with ros.rosPackages.humble; buildEnv { paths = [ ros-core rmw-fastrtps-dynamic-cpp + rviz2 ]; }) ]; @@ -76,7 +87,7 @@ RMW_IMPLEMENTATION = "rmw_fastrtps_dynamic_cpp"; }; - all = pkgs.mkShell { packages = with pkgs; [ fstl mayo cad-gen cg-gen ]; }; + all = pkgs.mkShell { packages = with pkgs; [ fstl cad-gen cg-gen ]; }; ci = pkgs.mkShell { buildInputs = [ pkgs.jq ]; }; @@ -98,12 +109,14 @@ tensorboardx albumentations simplejson + + ultralytics ]; in pkgs.mkShell { packages = [ pkgs.s3cmd pkgs.libGL ] ++ [ (pkgs.python3.withPackages perception-packages) ]; }; - }; + }; } ); diff --git a/pkgs/cmake-build-extension/default.nix b/pkgs/cmake-build-extension/default.nix new file mode 100644 index 0000000..92cb381 --- /dev/null +++ b/pkgs/cmake-build-extension/default.nix @@ -0,0 +1,50 @@ +{ + lib, + buildPythonPackage, + fetchFromGitHub, + setuptools, + setuptools-scm, + wheel, + gitpython, + cmake, + ninja, + pkg-config +}: + +buildPythonPackage rec { + pname = "cmake-build-extension"; + version = "0.6.1"; + pyproject = true; + + src = fetchFromGitHub { + owner = "diegoferigo"; + repo = "cmake-build-extension"; + rev = "v${version}"; + hash = "sha256-taAwxa7Sv+xc8xJRnNM6V7WPcL+TWZOkngwuqjAslzc="; + }; + + # nativeBuildInputs = [ cmake ]; + # buildInputs = [ cmake ninja ]; + dontUseCmakeConfigure = true; + + propagatedBuildInputs = [ gitpython ]; + + build-system = [ + cmake + ninja + setuptools + setuptools-scm + wheel + ]; + + pythonImportsCheck = [ + "cmake_build_extension" + ]; + + meta = { + description = "Setuptools extension to build and package CMake projects"; + homepage = "https://github.com/diegoferigo/cmake-build-extension"; + license = lib.licenses.mit; + maintainers = with lib.maintainers; [ ]; + }; +} diff --git a/pkgs/coremltools/default.nix b/pkgs/coremltools/default.nix new file mode 100644 index 0000000..a714377 --- /dev/null +++ b/pkgs/coremltools/default.nix @@ -0,0 +1,36 @@ +{ + lib, + buildPythonPackage, + fetchFromGitHub, + setuptools, + wheel, +}: + +buildPythonPackage rec { + pname = "coremltools"; + version = "8.0"; + pyproject = true; + + src = fetchFromGitHub { + owner = "apple"; + repo = "coremltools"; + rev = version; + hash = "sha256-nMrOtG8kAvz7DxYcf2Dh5f65zbTPSuUfoU7XL2Cx1Aw="; + }; + + build-system = [ + setuptools + wheel + ]; + + pythonImportsCheck = [ + "coremltools" + ]; + + meta = { + description = "Core ML tools contain supporting tools for Core ML model conversion, editing, and validation"; + homepage = "https://github.com/apple/coremltools"; + license = lib.licenses.bsd3; + maintainers = with lib.maintainers; [ ]; + }; +} diff --git a/pkgs/default.nix b/pkgs/default.nix index c72e865..76042d3 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -12,7 +12,7 @@ self: super: with self.lib; let pname = "bpy"; src = self.fetchurl { url = "https://download.blender.org/source/${old.pname}-${old.version}.tar.xz"; - hash = "sha256-3AAtguPDQMk4VcZoRzDQGAG2aaKbHMa3XuuZC6aecj8="; + hash = "sha256-4LfgcP9wbSNma6kOuZqFutuN+oC4SNro0zUb8l1Hr/k="; }; cmakeFlags = old.cmakeFlags ++ [ "-DWITH_PYTHON_INSTALL=OFF" @@ -44,6 +44,21 @@ in { }; }; + # Docker Images + + cad-gen-docker = self.dockerTools.buildImage { + name = "cad-gen-docker"; + tag = "latest"; + copyToRoot = self.buildEnv { + name = "image-root"; + paths = with self; [ cad-gen ]; + pathsToLink = [ "/bin" ]; + }; + }; + + tiny-process-library = self.callPackage ./scenario/tiny-process-library.nix { }; + ycm = self.callPackage ./scenario/ycm.nix { }; + # Python packages @@ -60,6 +75,20 @@ in { hash = "sha256-X1LTOfbIAMy6gToNYS0JpeJpHi0jHPsEjrnCq2c9U0E="; }; }); + # torchWithCuda = python-prev.torchWithCuda.overridePythonAttrs (oldAttrs: { + # extraRunpaths = [ "${super.lib.getLib self.cudaPackages.cuda_nvrtc}/lib" ]; + # postPhases = super.lib.optionals self.stdenv.hostPlatform.isUnix ["postPatchelfPhase" ]; + # postPatchelfPhase = '' + # while IFS= read -r -d $'\0' elf ; do + # for extra in $extraRunpaths ; do + # echo patchelf "$elf" --add-rpath "$extra" >&2 + # patchelf "$elf" --add-rpath "$extra" + # done + # done < <( + # find "''${!outputLib}" "$out" -type f -iname '*.so' -print0 + # ) + # ''; + # }); torchvision = python-prev.torchvision.override { torch = python-final.pytorchWithCuda; }; @@ -70,6 +99,9 @@ in { torch = python-final.pytorchWithCuda; torchvision = python-final.torchvision; }; + ultralytics-thop = self.python3Packages.callPackage ./ultralytics-thop { torch = python-final.pytorchWithCuda; }; + coremltools = self.python3Packages.callPackage ./coremltools { }; + ultralytics = self.python3Packages.callPackage ./ultralytics { inherit (python-final) coremltools ultralytics-thop; torch = python-final.pytorchWithCuda; }; unified-planning = self.python3Packages.callPackage ./unified-planning { }; bpy-wheel = self.python3Packages.callPackage ./bpy-wheel { }; pysdf = self.python3Packages.callPackage ./pysdf { }; @@ -84,6 +116,9 @@ in { rbs-workbench = self.python3Packages.callPackage ./freecad.robossembler { inherit (python-final) freecad-lib; inherit rbsFrameworkSrc; }; freecad-lib = self.python3Packages.toPythonModule (self.callPackage ./freecad-lib { }); bpy-lib = self.python3Packages.toPythonModule bpy; + cmake-build-extension = self.python3Packages.callPackage ./cmake-build-extension { }; + scenario = self.python3Packages.callPackage ./scenario { inherit (python-final) cmake-build-extension; }; + idyntree = self.python3Packages.callPackage ./idyntree { inherit (python-final) cmake-build-extension; }; } ) ]; diff --git a/pkgs/freecad.robossembler/default.nix b/pkgs/freecad.robossembler/default.nix index dafd9f8..83adcdf 100644 --- a/pkgs/freecad.robossembler/default.nix +++ b/pkgs/freecad.robossembler/default.nix @@ -32,7 +32,7 @@ buildPythonPackage rec { freecad-lib ]; - pythonImportsCheck = [ "freecad.robossembler" ]; + # pythonImportsCheck = [ "freecad.robossembler" ]; doCheck = false; diff --git a/pkgs/idyntree/cmake-fix-libxml2-find-package.patch b/pkgs/idyntree/cmake-fix-libxml2-find-package.patch new file mode 100644 index 0000000..8c2010d --- /dev/null +++ b/pkgs/idyntree/cmake-fix-libxml2-find-package.patch @@ -0,0 +1,13 @@ +diff --color -ur a/CMakeLists.txt b/CMakeLists.txt +--- a/CMakeLists.txt 2021-05-30 13:46:22.256040282 +0200 ++++ b/CMakeLists.txt 2021-05-30 14:15:42.530181216 +0200 +@@ -333,7 +333,7 @@ + # So, try first to find the CMake module provided by libxml2 package, then fallback + # on the CMake's FindLibXml2.cmake module (which can lack some definition, especially + # in static build case). +-find_package(LibXml2 QUIET NO_MODULE) ++find_package(LibXml2 QUIET MODULE) + if(DEFINED LIBXML2_VERSION_STRING) + set(LIBXML2_FOUND ON) + set(LIBXML2_INCLUDE_DIR ${LIBXML2_INCLUDE_DIRS}) +Seulement dans b: good.patch \ No newline at end of file diff --git a/pkgs/idyntree/default.nix b/pkgs/idyntree/default.nix new file mode 100644 index 0000000..66a4b8d --- /dev/null +++ b/pkgs/idyntree/default.nix @@ -0,0 +1,62 @@ +{ + lib, + buildPythonPackage, + fetchFromGitHub, + cmake, + ninja, + cmake-build-extension, + numpy, + setuptools, + setuptools-scm, + wheel, + eigen, + libxml2, + assimp, + swig, + pybind11, +}: + +buildPythonPackage rec { + pname = "idyntree"; + version = "13.1.1"; + pyproject = true; + + src = fetchFromGitHub { + owner = "robotology"; + repo = "idyntree"; + rev = "v${version}"; + hash = "sha256-OD00X5xjcti7GthAkluM7GxUHZ9tl0ne4HhflHsW2qk="; + }; + + nativeBuildInputs = [ swig pybind11 ]; + + buildInputs = [ assimp eigen libxml2.dev ]; + + build-system = [ + cmake + ninja + cmake-build-extension + numpy + setuptools + setuptools-scm + wheel + ]; + + dontUseCmakeConfigure = true; + + cmakeFlags = [ + "-DIDYNTREE_USES_PYTHON_PYBIND11='ON'" + ]; + + pythonImportsCheck = [ + "idyntree" + ]; + + meta = { + description = "Multibody Dynamics Library designed for Free Floating Robots"; + homepage = "https://github.com/robotology/idyntree"; + changelog = "https://github.com/robotology/idyntree/blob/${src.rev}/CHANGELOG.md"; + license = lib.licenses.bsd3; + maintainers = with lib.maintainers; [ ]; + }; +} diff --git a/pkgs/scenario/default.nix b/pkgs/scenario/default.nix new file mode 100644 index 0000000..daf2a52 --- /dev/null +++ b/pkgs/scenario/default.nix @@ -0,0 +1,86 @@ +{ + lib, + buildPythonPackage, + fetchFromGitHub, + cmake, + ninja, + cmake-build-extension, + #idyntree, + setuptools, + setuptools-scm, + wheel, + tiny-process-library, + ycm, + pkg-config, + fetchFromGitLab +}: + +let + ycm-src = fetchFromGitHub { + owner = "robotology"; + repo = "ycm"; + rev = "0.16.9"; + hash = "sha256-39DH8plnksLOz2XNcE3qQClD81NIGeJGQszBxVAAsUE="; + }; + + tpl-src = fetchFromGitLab { + owner = "eidheim"; + repo = "tiny-process-library"; + rev = "2.0.4"; + hash = "sha256-ntg0e3Ox5swCoimZG6gwpD2eKKFQx5+vXq77cK+wT1Y="; + }; +in + +buildPythonPackage rec { + pname = "scenario"; + version = "1.4.0"; + pyproject = true; + + src = fetchFromGitHub { + owner = "movefasta"; + repo = "scenario"; + rev = "6bf8f7227778a55aef335599e8d127c061af5bf6"; + hash = "sha256-QWBVIr4WaPHLzoRNm8p781k3obvywP+s0YbqP1+Tzd0="; + }; + + patches = [ ./ignition.patch ]; + + postPatch = '' + substituteInPlace deps/CMakeLists.txt \ + --replace "GIT_REPOSITORY https://github.com/robotology/ycm.git" "SOURCE_DIR ${ycm-src}" \ + --replace "GIT_REPOSITORY https://gitlab.com/eidheim/tiny-process-library.git" "SOURCE_DIR ${tpl-src}" \ + --replace "SCENARIO_CALL_FROM_SETUP_PY AND NOT USE_IGNITION" "FALSE" + substituteInPlace pyproject.toml --replace-fail '"idyntree>=3.1",' "" + substituteInPlace setup.py --replace-fail 'cmake_depends_on=["idyntree"],' "" + ''; + + # nativeBuildInputs = [ pkg-config ]; + + build-system = [ + cmake + ninja + cmake-build-extension + #idyntree + setuptools + setuptools-scm + wheel + ]; + + cmakeFlags = [ + "-DSCENARIO_USE_IGNITION=FALSE" + "-DSCENARIO_BUILD_SHARED_LIBRARY=ON" + ]; + + dontUseCmakeConfigure = true; + + pythonImportsCheck = [ + "scenario" + ]; + + meta = { + description = ""; + homepage = "https://github.com/movefasta/scenario"; + license = lib.licenses.mit; + maintainers = with lib.maintainers; [ ]; + }; +} diff --git a/pkgs/scenario/ignition.patch b/pkgs/scenario/ignition.patch new file mode 100644 index 0000000..20e950d --- /dev/null +++ b/pkgs/scenario/ignition.patch @@ -0,0 +1,12 @@ +diff --git a/setup.py b/setup.py +index 9352f44..e204b0d 100644 +--- a/setup.py ++++ b/setup.py +@@ -16,6 +16,7 @@ setuptools.setup( + cmake_configure_options=[ + "-DSCENARIO_CALL_FROM_SETUP_PY:BOOL=ON", + "-DSCENARIO_BUILD_SHARED_LIBRARY:BOOL=OFF", ++ '-DIGNITION_DISTRIBUTION="ignition-gazebo"', + f"-DPython3_EXECUTABLE:PATH={sys.executable}", + ], + disable_editable=True, diff --git a/pkgs/scenario/mkder.nix b/pkgs/scenario/mkder.nix new file mode 100644 index 0000000..b882230 --- /dev/null +++ b/pkgs/scenario/mkder.nix @@ -0,0 +1,31 @@ +{ + lib, + stdenv, + fetchFromGitHub, + cmake, +}: + +stdenv.mkDerivation rec { + pname = "scenario"; + version = "unstable-2024-10-08"; + + src = fetchFromGitHub { + owner = "movefasta"; + repo = "scenario"; + rev = "6bf8f7227778a55aef335599e8d127c061af5bf6"; + hash = "sha256-QWBVIr4WaPHLzoRNm8p781k3obvywP+s0YbqP1+Tzd0="; + }; + + nativeBuildInputs = [ + cmake + ]; + + meta = { + description = ""; + homepage = "https://github.com/movefasta/scenario"; + license = lib.licenses.unfree; # FIXME: nix-init did not find a license + maintainers = with lib.maintainers; [ ]; + mainProgram = "scenario"; + platforms = lib.platforms.all; + }; +} diff --git a/pkgs/scenario/tiny-process-library.nix b/pkgs/scenario/tiny-process-library.nix new file mode 100644 index 0000000..646a233 --- /dev/null +++ b/pkgs/scenario/tiny-process-library.nix @@ -0,0 +1,31 @@ +{ + lib, + stdenv, + fetchFromGitLab, + cmake, +}: + +stdenv.mkDerivation rec { + pname = "tiny-process-library"; + version = "2.0.4"; + + src = fetchFromGitLab { + owner = "eidheim"; + repo = "tiny-process-library"; + rev = "v${version}"; + hash = "sha256-ntg0e3Ox5swCoimZG6gwpD2eKKFQx5+vXq77cK+wT1Y="; + }; + + nativeBuildInputs = [ + cmake + ]; + + meta = { + description = "A small platform independent library making it simple to create and stop new processes in C++, as well as writing to stdin and reading from stdout and stderr of a new process"; + homepage = "https://gitlab.com/eidheim/tiny-process-library"; + license = lib.licenses.mit; + maintainers = with lib.maintainers; [ ]; + mainProgram = "tiny-process-library"; + platforms = lib.platforms.all; + }; +} diff --git a/pkgs/scenario/ycm.nix b/pkgs/scenario/ycm.nix new file mode 100644 index 0000000..085caae --- /dev/null +++ b/pkgs/scenario/ycm.nix @@ -0,0 +1,42 @@ +{ + lib, + stdenv, + fetchFromGitHub, + cmake, + pkg-config +}: +let + ycm-src = +in + +stdenv.mkDerivation rec { + pname = "ycm"; + version = "0.16.9"; + + src = fetchFromGitHub { + owner = "robotology"; + repo = "ycm"; + rev = "v${version}"; + hash = "sha256-39DH8plnksLOz2XNcE3qQClD81NIGeJGQszBxVAAsUE="; + }; + + + + nativeBuildInputs = [ + cmake + ]; + + propagatedBuildInputs = [ cmake pkg-config ]; + + # setupHook = ./setup-hook.sh; + + meta = { + description = "YCM (YCM CMake modules) is a collection of various useful CMake modules"; + homepage = "https://github.com/robotology/ycm"; + changelog = "https://github.com/robotology/ycm/blob/${src.rev}/CHANGELOG.md"; + license = lib.licenses.unfree; # FIXME: nix-init did not find a license + maintainers = with lib.maintainers; [ ]; + mainProgram = "ycm"; + platforms = lib.platforms.all; + }; +} diff --git a/pkgs/ultralytics-thop/default.nix b/pkgs/ultralytics-thop/default.nix new file mode 100644 index 0000000..7ff10dc --- /dev/null +++ b/pkgs/ultralytics-thop/default.nix @@ -0,0 +1,43 @@ +{ + lib, + buildPythonPackage, + fetchFromGitHub, + setuptools, + wheel, + numpy, + torch, +}: + +buildPythonPackage rec { + pname = "thop"; + version = "2.0.9"; + pyproject = true; + + src = fetchFromGitHub { + owner = "ultralytics"; + repo = "thop"; + rev = "v${version}"; + hash = "sha256-FzjxEk6yiG+IWwQEzsHcEAB4iVQT1QsyoGlG4I9lSwU="; + }; + + build-system = [ + setuptools + wheel + ]; + + dependencies = [ + numpy + torch + ]; + + pythonImportsCheck = [ + "ultralytics_thop" + ]; + + meta = { + description = "Profile PyTorch models for FLOPs and parameters, helping to evaluate computational efficiency and memory usage"; + homepage = "https://github.com/ultralytics/thop"; + license = lib.licenses.agpl3Only; + maintainers = with lib.maintainers; [ ]; + }; +} diff --git a/pkgs/ultralytics/default.nix b/pkgs/ultralytics/default.nix new file mode 100644 index 0000000..e85ff25 --- /dev/null +++ b/pkgs/ultralytics/default.nix @@ -0,0 +1,142 @@ +{ + lib, + buildPythonPackage, + fetchFromGitHub, + setuptools, + wheel, + matplotlib, + numpy, + opencv4, + pandas, + pillow, + psutil, + py-cpuinfo, + pyyaml, + requests, + scipy, + seaborn, + torch, + torchvision, + tqdm, + ultralytics-thop, + coverage, + ipython, + mkdocs, + mkdocs-jupyter, + #mkdocs-macros-plugin, + mkdocs-material, + mkdocs-redirects, + #mkdocs-ultralytics-plugin, + mkdocstrings, + pytest, + pytest-cov, + coremltools, + flatbuffers, + h5py, + keras, + onnx, + openvino, + scikit-learn, + tensorflow, + #tensorflowjs, + tensorstore, + albumentations, + #hub-sdk, + pycocotools, + #comet, + dvclive, + tensorboard, + shapely, + streamlit, +}: + +buildPythonPackage rec { + pname = "ultralytics"; + version = "8.3.14"; + pyproject = true; + + src = fetchFromGitHub { + owner = "ultralytics"; + repo = "ultralytics"; + rev = "v${version}"; + hash = "sha256-Hg8nUUVbwtXYXcrOkDKQ7IZSo4qqJPcXL4JGeRvsbIY="; + }; + + build-system = [ + setuptools + wheel + ]; + + dependencies = [ + matplotlib + numpy + opencv4 + pandas + pillow + psutil + py-cpuinfo + pyyaml + requests + scipy + seaborn + torch + torchvision + tqdm + ultralytics-thop + ]; + + optional-dependencies = { + dev = [ + coverage + ipython + mkdocs + mkdocs-jupyter + #mkdocs-macros-plugin + mkdocs-material + mkdocs-redirects + #mkdocs-ultralytics-plugin + mkdocstrings + pytest + pytest-cov + ]; + export = [ + coremltools + flatbuffers + h5py + keras + numpy + onnx + openvino + scikit-learn + tensorflow + #tensorflowjs + tensorstore + ]; + extra = [ + albumentations + #hub-sdk + ipython + pycocotools + ]; + logging = [ + # comet + dvclive + tensorboard + ]; + solutions = [ + shapely + streamlit + ]; + }; + + pythonImportsCheck = [ + "ultralytics" + ]; + + meta = { + description = "Ultralytics YOLO11"; + homepage = "https://github.com/ultralytics/ultralytics"; + license = lib.licenses.agpl3Only; + maintainers = with lib.maintainers; [ ]; + }; +}