joe-warren / opencascade-hs

Haskell Bindings for the OpenCASCADE CAD Kernel + A Declarative CAD/Solid Modeling Library
GNU Lesser General Public License v2.1
48 stars 5 forks source link

Nix Integration #9

Open joe-warren opened 3 months ago

joe-warren commented 3 months ago

At present, the hackage2Nix export of this project doesn't compile, because the opencascade occt libraries are missing (logs here).

opencascade-occt is packaged for nix (see here). So this should just require setting that package as a dependency.

I am however, reluctant to do this in such a way that it prevents building this project without using nix.

KMIJPH commented 3 months ago

I am unfortunately unable to build this on NixOS using the packaged opencascade-occt.

cpp/hs_Bnd_Box.cpp:1:10: error:
     fatal error: Bnd_Box.hxx: No such file or directory
        1 | #include <Bnd_Box.hxx>
          |          ^~~~~~~~~~~~~
  |
1 | #include <Bnd_Box.hxx>
  |          ^
compilation terminated.
`c++' failed in phase `C++ Compiler'. (Exit code: 1)
joe-warren commented 3 months ago

Ah, thanks, looks like it's failing to pick up the header files, which opencascade-hs assumes should be in /usr/include/opencascade.

If you can figure out where these are placed by the nix package, you could try setting either CPATH, or extra-include-dirs?

Thanks a lot for your help: much appreciated

KMIJPH commented 3 months ago

It does work by setting --extra-include-dirs.

cabal.project:

packages: *.cabal

package opencascade-hs
    extra-include-dirs: (output of find /nix/store -maxdepth 1 -name "*opencascade-occt-7.8.1")/include/opencascade

Unfortunately I am not the best with Haskell's tooling (and/or nix), so I have no idea how to integrate it elegantly in a nix package. Locally, for me this works well enough.

KMIJPH commented 3 months ago

Thanks for the lovely project :)

joe-warren commented 5 days ago

I built a minimal example of a waterfall-cad based project building within Nix

This should hopefully give Nix users a starting point

I'm still keeping this issue open; I'd like to get to the point where the package in haskellPackages just works, as opposed to at the moment, where you need to "do a bunch of nix stuff" to get the opencascade-hs package to build against the Nix packaged version of OpenCascade