Skip to content
Merged
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
21 changes: 21 additions & 0 deletions .github/workflows/nix.yml
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
7 changes: 5 additions & 2 deletions Sofa/GUI/Qt/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,11 @@ endif()

if (Qt6Core_FOUND)
message("${PROJECT_NAME}: will use Qt6")
sofa_find_package(Qt6 COMPONENTS Gui GuiTools Widgets WidgetsTools OpenGLWidgets REQUIRED)
set(SOFA_GUI_QT_TARETS ${SOFA_GUI_QT_TARGETS} Qt::Core Qt::Gui Qt::Widgets Qt::OpenGLWidgets )
find_package(Qt6 COMPONENTS Gui GuiTools Widgets WidgetsTools OpenGLWidgets REQUIRED)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not very familiar with Qt components. Can you give more details on the changes here? Thanks

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not familiar with those neither, but as a matter of fact, the Qt6GuiToolsConfig.cmake file does not define a Qt6::GuiTools CMake target. Therefore we can not rely on the presence of a Qt6::GuiTools CMake target to know how should we define SOFA_GUI_QT_HAVE_QT6.

But I don't know why we are looking for those CMake targets to define if SOFA_GUI_QT_HAVE_QT6 or not. My guess is that Qt6_FOUND should be enough.

# GuiTools & WidgetsTools does not define a Qt6::component CMake target
# So we can't look for those target to know how we should define SOFA_GUI_QT_HAVE_QT6
sofa_find_package(Qt6 COMPONENTS Gui Widgets OpenGLWidgets REQUIRED)
set(SOFA_GUI_QT_TARGETS ${SOFA_GUI_QT_TARGETS} Qt::Core Qt::Gui Qt::Widgets Qt::OpenGLWidgets )
elseif (Qt5Core_FOUND)
message("${PROJECT_NAME}: will use Qt5 (deprecated)")
sofa_find_package(Qt5 COMPONENTS Core Gui OpenGL REQUIRED)
Expand Down
6 changes: 3 additions & 3 deletions cmake/Modules/FindQGLViewer.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ if(NOT TARGET QGLViewer)

if(NOT QGLViewer_INCLUDE_DIR)
find_path(QGLViewer_INCLUDE_DIR
NAMES qglviewer.h
PATH_SUFFIXES include/QGLViewer
NAMES QGLViewer/qglviewer.h
PATH_SUFFIXES include Headers
)
endif()

if(NOT QGLViewer_LIBRARY)
find_library(QGLViewer_LIBRARY
NAMES QGLViewer QGLViewer2 QGLViewer-qt5
NAMES QGLViewer QGLViewer2 QGLViewer-qt5 QGLViewer-qt6
PATH_SUFFIXES lib
)
endif()
Expand Down
108 changes: 108 additions & 0 deletions flake.lock

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

37 changes: 37 additions & 0 deletions flake.nix
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 { };
};
};
};
}
82 changes: 82 additions & 0 deletions package.nix
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;
};
}