Skip to content

Commit

Permalink
Merge pull request #36 from agimus-project/flake
Browse files Browse the repository at this point in the history
Nix: initial packaging + CI
  • Loading branch information
nim65s authored Dec 12, 2024
2 parents 5e1d569 + 913745e commit db40549
Show file tree
Hide file tree
Showing 4 changed files with 162 additions and 0 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/nix.yml
Original file line number Diff line number Diff line change
@@ -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
54 changes: 54 additions & 0 deletions default.nix
Original file line number Diff line number Diff line change
@@ -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;
};
}
58 changes: 58 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 30 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -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; }
);
};
};
};
}

0 comments on commit db40549

Please sign in to comment.