{ lib , cmake , coin3d , doxygen , eigen , fetchFromGitHub , fmt , freecad , gfortran , gts , hdf5 , libf2c , libGLU , libredwg , libsForQt5 , libspnav , libXmu , medfile , mpi , ninja , ode , opencascade-occt_7_6 , pkg-config , python311Packages , runCommand # for passthru.tests , spaceNavSupport ? stdenv.hostPlatform.isLinux , stdenv , swig , vtk , wrapGAppsHook3 , xercesc , yaml-cpp , zlib , withWayland ? false }: let opencascade-occt = opencascade-occt_7_6; inherit (libsForQt5) qtbase qttools qtwebengine qtx11extras qtxmlpatterns soqt wrapQtAppsHook ; inherit (libsForQt5.qt5) qtwayland; inherit (python311Packages) boost gitpython matplotlib pivy ply pybind11 pycollada pyside2 pyside2-tools python pyyaml scipy shiboken2 ; in stdenv.mkDerivation (finalAttrs: { pname = "freecad"; version = "1.0rc4"; src = fetchFromGitHub { owner = "FreeCAD"; repo = "FreeCAD"; rev = finalAttrs.version; hash = "sha256-b7aeVQkgdsDRdnVIr+5ZNuWAm6GLH7sepa8kFp2Zm2U="; fetchSubmodules = true; }; nativeBuildInputs = [ cmake ninja pkg-config pyside2-tools gfortran wrapQtAppsHook wrapGAppsHook3 ]; buildInputs = [ gitpython # for addon manager boost coin3d doxygen eigen fmt gts hdf5 libGLU libXmu libf2c matplotlib medfile mpi ode opencascade-occt pivy ply # for openSCAD file support pybind11 pycollada pyside2 pyside2-tools python pyyaml # (at least for) PyrateWorkbench qtbase qttools qtwayland qtwebengine qtxmlpatterns scipy shiboken2 soqt swig vtk xercesc yaml-cpp zlib ] ++ lib.optionals spaceNavSupport [ libspnav qtx11extras ]; patches = [ ./0001-NIXOS-don-t-ignore-PYTHONPATH.patch ./0002-FreeCad-OndselSolver-pkgconfig.patch ]; cmakeFlags = [ "-Wno-dev" # turns off warnings which otherwise makes it hard to see what is going on "-DBUILD_FLAT_MESH:BOOL=ON" "-DBUILD_QT5=ON" "-DBUILD_DRAWING=ON" "-DBUILD_FLAT_MESH:BOOL=ON" "-DINSTALL_TO_SITEPACKAGES=OFF" "-DFREECAD_USE_PYBIND11=ON" "-DSHIBOKEN_INCLUDE_DIR=${shiboken2}/include" "-DSHIBOKEN_LIBRARY=Shiboken2::libshiboken" ( "-DPYSIDE_INCLUDE_DIR=${pyside2}/include" + ";${pyside2}/include/PySide2/QtCore" + ";${pyside2}/include/PySide2/QtWidgets" + ";${pyside2}/include/PySide2/QtGui" ) "-DPYSIDE_LIBRARY=PySide2::pyside2" ]; # This should work on both x86_64, and i686 linux preBuild = '' export NIX_LDFLAGS="-L${gfortran.cc}/lib64 -L${gfortran.cc}/lib $NIX_LDFLAGS"; ''; preConfigure = '' qtWrapperArgs+=(--prefix PYTHONPATH : "$PYTHONPATH") ''; qtWrapperArgs = [ "--set COIN_GL_NO_CURRENT_CONTEXT_CHECK 1" "--prefix PATH : ${libredwg}/bin" ] ++ lib.optionals (!withWayland) [ "--set QT_QPA_PLATFORM xcb" ]; postFixup = '' mv $out/share/doc $out ln -s $out/bin/FreeCAD $out/bin/freecad ln -s $out/bin/FreeCADCmd $out/bin/freecadcmd ''; passthru.tests = { # Check that things such as argument parsing still work correctly with # the above PYTHONPATH patch. Previously the patch used above changed # the `PyConfig_InitIsolatedConfig` to `PyConfig_InitPythonConfig`, # which caused the built-in interpreter to attempt (and fail) to doubly # parse argv. This should catch if that ever regresses and also ensures # that PYTHONPATH is still respected enough for the FreeCAD console to # successfully run and check that it was included in `sys.path`. python-path = runCommand "freecad-test-console" { nativeBuildInputs = [ freecad ]; } '' HOME="$(mktemp -d)" PYTHONPATH="$(pwd)/test" FreeCADCmd --log-file $out -c "if not '$(pwd)/test' in sys.path: sys.exit(1)"