Wrapping CMake in Nix Flakes

Currently there are wrappers for gnu Make.

Would there be a wrapper for cmake? For example, the following result produced by nix flake is not correct

installPhase = "cmake --install build";

You can just add cmake to nativeBuildInputs and the default phases will be replaced, see the relevant manual section.

The setup hook does not currently cover installPhase but by default CMake will use the install target in the generated Makefile so the default installPhase should work.

Thank you for your quick reply. I tried your approach and it did work for the binary generated. Could you perhaps elaborate how to do this for generated library files. In particular, the generated Package.cmake still has the wrong absolute path.

That sounds like the project’s CMake build scripts make some incorrect assumptions like hardcoding the installation paths or considering CMAKE_INSTALL_<dir> a relative path.

The project itself will need to be fixed. Though in the latter case, you can also work around it by setting the relevant configuration flags back to relative paths, for example by adding cmakeFlags = [ "-DCMAKE_INSTALL_LIBDIR=lib" ];.

Thank you for your kind help! Indeed I need to modify the Cmakelist.txt to make this work!