diff --git a/.github/workflows/nix.yml b/.github/workflows/nix.yml new file mode 100644 index 0000000..1c320d7 --- /dev/null +++ b/.github/workflows/nix.yml @@ -0,0 +1,20 @@ +name: "CI - Nix" + +on: + push: + +jobs: + nix: + runs-on: "${{ matrix.os }}-latest" + strategy: + matrix: + os: [ubuntu, macos] + steps: + - uses: actions/checkout@v4 + - uses: cachix/install-nix-action@v27 + - uses: cachix/cachix-action@v15 + with: + name: gepetto + authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' + - run: nix build -L .#colmpc + - run: nix build -L .#py-colmpc diff --git a/default.nix b/default.nix new file mode 100644 index 0000000..cbbeaea --- /dev/null +++ b/default.nix @@ -0,0 +1,54 @@ +{ + lib, + stdenv, + cmake, + crocoddyl, + ipopt, + llvmPackages, + pkg-config, + python3Packages, + pythonSupport ? false, +}: + +stdenv.mkDerivation { + pname = "colmpc"; + version = "0.2.0"; + + src = lib.fileset.toSource { + root = ./.; + fileset = lib.fileset.unions [ + ./CMakeLists.txt + ./include + ./package.xml + ./python + ./tests + ]; + }; + + nativeBuildInputs = [ + cmake + pkg-config + ] ++ lib.optional pythonSupport python3Packages.pythonImportsCheckHook; + + buildInputs = lib.optional stdenv.cc.isClang llvmPackages.openmp; + + propagatedBuildInputs = + [ ipopt ] + ++ lib.optional pythonSupport python3Packages.crocoddyl + ++ lib.optional (!pythonSupport) crocoddyl; + + cmakeFlags = [ + (lib.cmakeBool "BUILD_PYTHON_INTERFACE" pythonSupport) + ]; + + doCheck = true; + pythonImportsCheck = [ "colmpc" ]; + + meta = { + description = "Collision avoidance for MPC"; + homepage = "https://github.com/agimus-project/colmpc"; + license = lib.licenses.bsd2; + maintainers = with lib.maintainers; [ nim65s ]; + platforms = lib.platforms.unix; + }; +} diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..e4c3565 --- /dev/null +++ b/flake.lock @@ -0,0 +1,58 @@ +{ + "nodes": { + "flake-parts": { + "inputs": { + "nixpkgs-lib": "nixpkgs-lib" + }, + "locked": { + "lastModified": 1733312601, + "narHash": "sha256-4pDvzqnegAfRkPwO3wmwBhVi/Sye1mzps0zHWYnP88c=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "205b12d8b7cd4802fbcb8e8ef6a0f1408781a4f9", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1733759999, + "narHash": "sha256-463SNPWmz46iLzJKRzO3Q2b0Aurff3U1n0nYItxq7jU=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "a73246e2eef4c6ed172979932bc80e1404ba2d56", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-lib": { + "locked": { + "lastModified": 1733096140, + "narHash": "sha256-1qRH7uAUsyQI7R1Uwl4T+XvdNv778H0Nb5njNrqvylY=", + "type": "tarball", + "url": "https://github.com/NixOS/nixpkgs/archive/5487e69da40cbd611ab2cadee0b4637225f7cfae.tar.gz" + }, + "original": { + "type": "tarball", + "url": "https://github.com/NixOS/nixpkgs/archive/5487e69da40cbd611ab2cadee0b4637225f7cfae.tar.gz" + } + }, + "root": { + "inputs": { + "flake-parts": "flake-parts", + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..4d94156 --- /dev/null +++ b/flake.nix @@ -0,0 +1,30 @@ +{ + description = "Collision avoidance for MPC"; + + inputs = { + flake-parts.url = "github:hercules-ci/flake-parts"; + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + }; + + outputs = + inputs: + inputs.flake-parts.lib.mkFlake { inherit inputs; } { + systems = inputs.nixpkgs.lib.systems.flakeExposed; + perSystem = + { pkgs, self', ... }: + { + apps.default = { + type = "app"; + program = pkgs.python3.withPackages (_: [ self'.packages.default ]); + }; + devShells.default = pkgs.mkShell { inputsFrom = [ self'.packages.default ]; }; + packages = { + default = self'.packages.py-colmpc; + colmpc = pkgs.callPackage ./. { }; + py-colmpc = pkgs.python3Packages.toPythonModule ( + self'.packages.colmpc.override { pythonSupport = true; } + ); + }; + }; + }; +}