lol
1{
2 lib,
3 stdenv,
4 fetchurl,
5 autoreconfHook,
6 autoconf-archive,
7 pkg-config,
8 kmod,
9 enable-tools ? true,
10 enablePython ? false,
11 python3,
12 ncurses,
13}:
14
15stdenv.mkDerivation rec {
16 pname = "libgpiod";
17 version = "1.6.4";
18
19 src = fetchurl {
20 url = "https://git.kernel.org/pub/scm/libs/libgpiod/libgpiod.git/snapshot/libgpiod-${version}.tar.gz";
21 hash = "sha256-gp1KwmjfB4U2CdZ8/H9HbpqnNssqaKYwvpno+tGXvgo=";
22 };
23
24 patches = [
25 # cross compiling fix
26 # https://github.com/brgl/libgpiod/pull/45
27 ./0001-Drop-AC_FUNC_MALLOC-and-_REALLOC-and-check-for-them-.patch
28 ];
29
30 buildInputs = [
31 kmod
32 ]
33 ++ lib.optionals enablePython [
34 python3
35 ncurses
36 ];
37 nativeBuildInputs = [
38 autoconf-archive
39 pkg-config
40 autoreconfHook
41 ];
42
43 configureFlags = [
44 "--enable-tools=${if enable-tools then "yes" else "no"}"
45 "--enable-bindings-cxx"
46 "--prefix=${placeholder "out"}"
47 ]
48 ++ lib.optional enablePython "--enable-bindings-python";
49
50 meta = with lib; {
51 description = "C library and tools for interacting with the linux GPIO character device";
52 longDescription = ''
53 Since linux 4.8 the GPIO sysfs interface is deprecated. User space should use
54 the character device instead. This library encapsulates the ioctl calls and
55 data structures behind a straightforward API.
56 '';
57 homepage = "https://git.kernel.org/pub/scm/libs/libgpiod/libgpiod.git/about/";
58 license = licenses.lgpl2;
59 maintainers = [ ];
60 platforms = platforms.linux;
61 };
62}