forked from sofa-framework/sofa
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[workflow][Nix] initial packaging & flake (sofa-framework#5059)
* [Nix] initial packaging & flake * [Nix] setup CI * [CMake] FindQGLViewer: fix include dir computation we use `#include <QGLViewer/qglviewer.h>`, so `QGLViewer_INCLUDE_DIR` must not include `QGLViewer` component. Also, on darwin, headers are installed in Headers dir, not include, ref: https://github.com/GillesDebunne/libQGLViewer/blob/ba9a875784afbb7ee73088fe0e8701c31bc7277d/QGLViewer/QGLViewer.pro#L138 * [Nix] fix build on macos This require fixes in upstream nixpkgs: NixOS/nixpkgs#348549 So we can use the source of that PR for now * [CMake] FindQGLViewer: fix for Qt6 ref. https://github.com/GillesDebunne/libQGLViewer/blob/ba9a875784afbb7ee73088fe0e8701c31bc7277d/QGLViewer/QGLViewer.pro#L176 * [Nix] Qt5 -> Qt6 * [CMake] fix typo for Qt6 * [CMake] fix SOFA_GUI_QT_HAVE_QT6 definition without this, `lib/cmake/Sofa.GUI.Qt/Sofa.GUI.QtConfig.cmake` has: > `set(SOFA_GUI_QT_HAVE_QT6 0)` and therefore, in SofaPython3, `find_package(QGLViewer QUIET REQUIRED)` is not called, and build ends up with: > [ 98%] Linking CXX shared library ../../lib/python3/site-packages/Sofa/Gui.cpython-312-x86_64-linux-gnu.so > […]/ld: cannot find -lQGLViewer: No such file or directory * [Nix] fixup lib path on Darwin TODO: This should be fixed in CMake instead, but I have no clue. error was: > dyld[61665]: Library not loaded: /nix/store/aalbn4pznxwy18ydjmb15c3y4izj8isi-sofa-24.06.00/lib/libSceneChecking.24.12.99.dylib > Referenced from: <8B75C775-7FE5-3755-A190-B11A3F4F6666> /nix/store/aalbn4pznxwy18ydjmb15c3y4izj8isi-sofa-24.06.00/bin/.runSofa-24.12.99-wrapped > Reason: tried: '/nix/store/aalbn4pznxwy18ydjmb15c3y4izj8isi-sofa-24.06.00/lib/libSceneChecking.24.12.99.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/nix/store/aalbn4pznxwy18ydjmb15c3y4izj8isi-sofa-24.06.00/lib/libSceneChecking.24.12.99.dylib' (no such file), '/nix/store/aalbn4pznxwy18ydjmb15c3y4izj8isi-sofa-24.06.00/lib/libSceneChecking.24.12.99.dylib' (no such file), '/usr/local/lib/libSceneChecking.24.12.99.dylib' (no such file), '/usr/lib/libSceneChecking.24.12.99.dylib' (no such file, not in dyld cache) > zsh: abort ./result/bin/runSofa * [Nix] CI on macos too * nix: add nixGL * [Nix] fix package description Co-authored-by: Hugo <[email protected]> * Apply suggestions from code review --------- Co-authored-by: Hugo <[email protected]>
- Loading branch information
Showing
6 changed files
with
256 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
name: "CI - Nix" | ||
|
||
on: | ||
push: | ||
|
||
jobs: | ||
nix: | ||
runs-on: "${{ matrix.os }}-latest" | ||
if: ${{ github.repository_owner == 'sofa-framework' }} | ||
strategy: | ||
matrix: | ||
os: [ubuntu, macos] | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: cachix/install-nix-action@v27 | ||
# TODO: the "sofa" account on cachix does not exist yet | ||
#- uses: cachix/cachix-action@v15 | ||
#with: | ||
#name: sofa | ||
#authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' | ||
- run: nix build -L |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
{ | ||
description = "SOFA is an open-source framework for interactive physics simulation, with emphasis on biomechanical and robotic simulations"; | ||
|
||
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"; | ||
nixgl.url = "github:nix-community/nixGL"; | ||
}; | ||
|
||
outputs = | ||
inputs@{ flake-parts, nixgl, nixpkgs, ... }: | ||
flake-parts.lib.mkFlake { inherit inputs; } { | ||
systems = nixpkgs.lib.systems.flakeExposed; | ||
perSystem = | ||
{ pkgs, self', system, ... }: | ||
{ | ||
_module.args.pkgs = import nixpkgs { | ||
inherit system; | ||
overlays = [ nixgl.overlay ]; | ||
}; | ||
apps.nixgl = { | ||
type = "app"; | ||
program = pkgs.writeShellApplication { | ||
name = "nixgl-sofa"; | ||
text = "${pkgs.lib.getExe pkgs.nixgl.auto.nixGLDefault} ${pkgs.lib.getExe self'.packages.sofa}"; | ||
}; | ||
}; | ||
devShells.default = pkgs.mkShell { inputsFrom = [ self'.packages.default ]; }; | ||
packages = { | ||
default = self'.packages.sofa; | ||
sofa = pkgs.callPackage ./package.nix { }; | ||
}; | ||
}; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
{ | ||
boost, | ||
cmake, | ||
cxxopts, | ||
eigen, | ||
#fetchFromGitHub, | ||
glew, | ||
gtest, | ||
lib, | ||
qt6Packages, | ||
libGL, | ||
metis, | ||
stdenv, | ||
tinyxml-2, | ||
zlib, | ||
}: | ||
|
||
stdenv.mkDerivation { | ||
pname = "sofa"; | ||
version = "24.06.00"; | ||
|
||
src = lib.fileset.toSource { | ||
root = ./.; | ||
fileset = lib.fileset.unions [ | ||
./applications | ||
./Authors.txt | ||
./cmake | ||
./CHANGELOG.md | ||
./CMakeLists.txt | ||
./CMakePresets.json | ||
./examples | ||
./extlibs | ||
./LICENSE-LGPL.md | ||
./package.cmake | ||
./README.md | ||
./scripts | ||
./share | ||
./Sofa | ||
./tools | ||
]; | ||
}; | ||
|
||
propagatedNativeBuildInputs = [ | ||
cmake | ||
qt6Packages.wrapQtAppsHook | ||
]; | ||
propagatedBuildInputs = [ | ||
boost | ||
cxxopts | ||
eigen | ||
glew | ||
gtest | ||
qt6Packages.libqglviewer | ||
qt6Packages.qtbase | ||
libGL | ||
metis | ||
tinyxml-2 | ||
zlib | ||
]; | ||
|
||
cmakeFlags = [ | ||
(lib.cmakeBool "SOFA_ALLOW_FETCH_DEPENDENCIES" false) | ||
]; | ||
|
||
doCheck = true; | ||
|
||
postFixup = lib.optionalString stdenv.hostPlatform.isDarwin '' | ||
install_name_tool -change \ | ||
$out/lib/libSceneChecking.24.12.99.dylib \ | ||
$out/plugins/SceneChecking/lib/libSceneChecking.24.12.99.dylib \ | ||
$out/bin/.runSofa-24.12.99-wrapped | ||
''; | ||
|
||
meta = { | ||
description = "SOFA is an open-source framework for interactive physics simulation, with emphasis on biomechanical and robotic simulations"; | ||
homepage = "https://github.com/sofa-framework/sofa"; | ||
license = lib.licenses.lgpl21Only; | ||
maintainers = with lib.maintainers; [ nim65s ]; | ||
mainProgram = "runSofa"; | ||
platforms = lib.platforms.unix ++ lib.platforms.windows; | ||
}; | ||
} |