Skip to content

Commit 60b5b5d

Browse files
authored
Nix: initial packaging & flake (#465)
* [Nix] initial packaging & flake * [Nix] setup CI * [Nix] Qt5 -> Qt6 * [Nix] CI on macos too
1 parent 7eb672c commit 60b5b5d

File tree

4 files changed

+207
-0
lines changed

4 files changed

+207
-0
lines changed

.github/workflows/nix.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: "CI - Nix"
2+
3+
on:
4+
push:
5+
6+
jobs:
7+
nix:
8+
runs-on: "${{ matrix.os }}-latest"
9+
strategy:
10+
matrix:
11+
os: [ubuntu, macos]
12+
steps:
13+
- uses: actions/checkout@v4
14+
- uses: cachix/install-nix-action@v27
15+
#- uses: cachix/cachix-action@v15
16+
#with:
17+
#name: sofa
18+
#authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
19+
- run: nix build -L

flake.lock

Lines changed: 82 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
{
2+
description = "Real-time multi-physics simulation with an emphasis on medical simulation.";
3+
4+
inputs = {
5+
flake-parts.url = "github:hercules-ci/flake-parts";
6+
#nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
7+
# ref. https://github.com/NixOS/nixpkgs/pull/348549
8+
nixpkgs.url = "github:nim65s/nixpkgs/qt6-libqglviewer";
9+
sofa = {
10+
url = "github:nim65s/sofa"; # update this after PR
11+
inputs = {
12+
flake-parts.follows = "flake-parts";
13+
nixpkgs.follows = "nixpkgs";
14+
};
15+
};
16+
};
17+
18+
outputs =
19+
inputs:
20+
inputs.flake-parts.lib.mkFlake { inherit inputs; } {
21+
systems = inputs.nixpkgs.lib.systems.flakeExposed;
22+
perSystem =
23+
{
24+
pkgs,
25+
self',
26+
system,
27+
...
28+
}:
29+
{
30+
apps.default = {
31+
type = "app";
32+
program =
33+
pkgs.runCommand "runSofa"
34+
{
35+
nativeBuildInputs = [ pkgs.makeBinaryWrapper ];
36+
meta.mainProgram = "runSofa";
37+
}
38+
''
39+
makeBinaryWrapper ${pkgs.lib.getExe self'.packages.sofa} $out/bin/runSofa \
40+
--set SOFA_PLUGIN_PATH ${self'.packages.sofa-python3} \
41+
--set SOFA_ROOT ${self'.packages.sofa} \
42+
--add-flags "-l SofaPython3"
43+
'';
44+
};
45+
devShells.default = pkgs.mkShell { inputsFrom = [ self'.packages.default ]; };
46+
packages = {
47+
inherit (inputs.sofa.packages.${system}) sofa;
48+
default = self'.packages.sofa-python3;
49+
sofa-python3 = pkgs.callPackage ./package.nix { inherit (self'.packages) sofa; };
50+
};
51+
};
52+
};
53+
}

package.nix

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
{
2+
cmake,
3+
lib,
4+
python3Packages,
5+
qt6Packages,
6+
sofa,
7+
stdenv,
8+
}:
9+
10+
stdenv.mkDerivation {
11+
pname = "sofa-python3";
12+
version = "24.06";
13+
14+
src = lib.fileset.toSource {
15+
root = ./.;
16+
fileset = lib.fileset.unions [
17+
./bindings
18+
./CMake
19+
./CMakeLists.txt
20+
./constants
21+
./docs
22+
./examples
23+
./Plugin
24+
./SofaPython3Config.cmake.in
25+
./splib
26+
./Testing
27+
];
28+
};
29+
30+
nativeBuildInputs = [
31+
cmake
32+
qt6Packages.libqglviewer
33+
qt6Packages.wrapQtAppsHook
34+
];
35+
propagatedBuildInputs = [
36+
python3Packages.pybind11
37+
python3Packages.scipy
38+
sofa
39+
];
40+
41+
# help locate FindQGLViewer.cmake
42+
cmakeFlags = [
43+
"-DCMAKE_MODULE_PATH=${sofa.src}/cmake/Modules"
44+
];
45+
46+
meta = {
47+
description = "python plugin for Sofa offering a pythonic interface and python3 support";
48+
homepage = "https://github.com/sofa-framework/SofaPython3";
49+
license = lib.licenses.lgpl21Only;
50+
maintainers = with lib.maintainers; [ nim65s ];
51+
platforms = lib.platforms.unix ++ lib.platforms.windows;
52+
};
53+
}

0 commit comments

Comments
 (0)