1{ lib
2, stdenv
3, fetchFromGitHub
4, nixosTests
5, cmake
6, pkg-config
7, AppKit
8, ApplicationServices
9, Carbon
10, libX11
11, libxkbcommon
12, xinput
13, xorg
14}:
15
16stdenv.mkDerivation rec {
17 pname = "libuiohook";
18 version = "1.2.2";
19
20 src = fetchFromGitHub {
21 owner = "kwhat";
22 repo = pname;
23 rev = version;
24 sha256 = "1qlz55fp4i9dd8sdwmy1m8i4i1jy1s09cpmlxzrgf7v34w72ncm7";
25 };
26
27 nativeBuildInputs = [ cmake pkg-config ];
28
29 buildInputs =
30 if stdenv.isDarwin then [ AppKit ApplicationServices Carbon ]
31 else [
32 libX11
33 libxkbcommon
34 xinput
35 ] ++
36 (with xorg; [
37 libXau
38 libXdmcp
39 libXi
40 libXinerama
41 libXt
42 libXtst
43 libXext
44 libxkbfile
45 ]);
46
47 outputs = [ "out" "test" ];
48
49 # We build the tests, but they're only installed when using the "test" output.
50 # This will produce a "uiohook_tests" binary which can be run to test the
51 # functionality of the library on the current system.
52 # Running the test binary requires a running X11 session.
53 cmakeFlags = [
54 "-DENABLE_TEST:BOOL=ON"
55 ];
56
57 postInstall = ''
58 mkdir -p $test/share
59 cp ./uiohook_tests $test/share
60 '';
61
62 meta = with lib; {
63 description = "C library to provide global keyboard and mouse hooks from userland";
64 homepage = "https://github.com/kwhat/libuiohook";
65 license = licenses.gpl3Only;
66 platforms = platforms.all;
67 maintainers = with maintainers; [ anoa ];
68 };
69
70 passthru.tests.libuiohook = nixosTests.libuiohook;
71}