Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nix: initial packaging & flake #465

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .github/workflows/nix.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
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: sofa
#authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
- run: nix build -L
82 changes: 82 additions & 0 deletions flake.lock

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

53 changes: 53 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
description = "Real-time multi-physics simulation with an emphasis on medical simulation.";

inputs = {
flake-parts.url = "github:hercules-ci/flake-parts";
#nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
# ref. https://github.com/NixOS/nixpkgs/pull/348549
nixpkgs.url = "github:nim65s/nixpkgs/qt6-libqglviewer";
sofa = {
url = "github:nim65s/sofa"; # update this after PR
inputs = {
flake-parts.follows = "flake-parts";
nixpkgs.follows = "nixpkgs";
};
};
};

outputs =
inputs:
inputs.flake-parts.lib.mkFlake { inherit inputs; } {
systems = inputs.nixpkgs.lib.systems.flakeExposed;
perSystem =
{
pkgs,
self',
system,
...
}:
{
apps.default = {
type = "app";
program =
pkgs.runCommand "runSofa"
{
nativeBuildInputs = [ pkgs.makeBinaryWrapper ];
meta.mainProgram = "runSofa";
}
''
makeBinaryWrapper ${pkgs.lib.getExe self'.packages.sofa} $out/bin/runSofa \
--set SOFA_PLUGIN_PATH ${self'.packages.sofa-python3} \
--set SOFA_ROOT ${self'.packages.sofa} \
--add-flags "-l SofaPython3"
'';
};
devShells.default = pkgs.mkShell { inputsFrom = [ self'.packages.default ]; };
packages = {
inherit (inputs.sofa.packages.${system}) sofa;
default = self'.packages.sofa-python3;
sofa-python3 = pkgs.callPackage ./package.nix { inherit (self'.packages) sofa; };
};
};
};
}
53 changes: 53 additions & 0 deletions package.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
cmake,
lib,
python3Packages,
qt6Packages,
sofa,
stdenv,
}:

stdenv.mkDerivation {
pname = "sofa-python3";
version = "24.06";

src = lib.fileset.toSource {
root = ./.;
fileset = lib.fileset.unions [
./bindings
./CMake
./CMakeLists.txt
./constants
./docs
./examples
./Plugin
./SofaPython3Config.cmake.in
./splib
./Testing
];
};

nativeBuildInputs = [
cmake
qt6Packages.libqglviewer
qt6Packages.wrapQtAppsHook
];
propagatedBuildInputs = [
python3Packages.pybind11
python3Packages.scipy
sofa
];

# help locate FindQGLViewer.cmake
cmakeFlags = [
"-DCMAKE_MODULE_PATH=${sofa.src}/cmake/Modules"
];

meta = {
description = "python plugin for Sofa offering a pythonic interface and python3 support";
homepage = "https://github.com/sofa-framework/SofaPython3";
license = lib.licenses.lgpl21Only;
maintainers = with lib.maintainers; [ nim65s ];
platforms = lib.platforms.unix ++ lib.platforms.windows;
};
}