xbows-driver
xbows-driver copied to clipboard
Packaging for NixOS
In order to make this properly compile on NixOS, I use the following changes:
- Build
libcrc
andhidadpi-supercollider
outside of the driver using the same commit referenced as submodules. - A replaced
CMakeLists.txt
(see below) that will make cmake look for the 2 libraries mentioned above instead of using the vendored versions. - Patch a few referenced paths.
substituteInPlace
is a sed wrapper that handles escaping paths and the likes and${netpbm}
is a reference to netpbm from where we get thergb.txt
.
Replace CMakeLists.txt with this:
cmake_minimum_required(VERSION 3.5)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
find_library(HIDAPI_LIBRARY hidapi-libusb)
find_library(CRC_LIBRARY crc)
find_library(YAML_LIBRARY yaml-cpp)
add_subdirectory(src)
And the patches:
for f in kbdtest.cc kbdtest2.cc xbows.hh ; do
substituteInPlace src/$f --replace '<hidapi' '<hidapi/hidapi'
done
substituteInPlace src/driver_parse.cc \
--replace /usr/share/X11/rgb.txt ${netpbm}/share/netpbm/misc/rgb.txt
sed -i src/CMakeLists.txt \
-e '/crap/d'
The full nix expressions is here: https://gist.github.com/peterhoeg/af34a63cd5c4a259a783e8764f637770
If we can fix the cmake to correctly work in the NixOS env, I'd rather do that than use a script to edit the cmake config. If I can use find_library and then fall back to building the included version, would that work?
If we can fix the cmake to correctly work in the NixOS env, I'd rather do that than use a script to edit the cmake config
I'm 100% with you on this. NixOS is a little special, so we often have to work around things but it's BY FAR preferable to have proper support upstream.
That being said, it looks like NixOS will be the first distribution to start carrying your work!
If I can use find_library and then fall back to building the included version, would that work?
Yep, that sounds like the way to go. Just FYI, on latest master (2146ead780f7f8cb1de3f46b2e47548dcc1c0816), I still need to use my CMakeLists.txt and the manual install you can see in the installPhase part.
How does the hidapi.h header get found with your changes? The cmake edits you make don't make that clear to me. Is it in /usr/include?
I'm not a cmake guru at all, but I guess that find_library
uses pkgconfig
to locate the include files.