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