1{ stdenv
2, lib
3, fetchFromGitHub
4, cmake
5, pkg-config
6, systemd
7, runtimeShell
8, python3
9, nixosTests
10}:
11
12let
13 version = "2.4.2";
14
15 src = fetchFromGitHub {
16 owner = "rvaiya";
17 repo = "keyd";
18 rev = "v" + version;
19 hash = "sha256-QWr+xog16MmybhQlEWbskYa/dypb9Ld54MOdobTbyMo=";
20 };
21
22 pypkgs = python3.pkgs;
23
24 appMap = pypkgs.buildPythonApplication rec {
25 pname = "keyd-application-mapper";
26 inherit version src;
27 format = "other";
28
29 postPatch = ''
30 substituteInPlace scripts/${pname} \
31 --replace /bin/sh ${runtimeShell}
32 '';
33
34 propagatedBuildInputs = with pypkgs; [ xlib ];
35
36 dontBuild = true;
37
38 installPhase = ''
39 install -Dm555 -t $out/bin scripts/${pname}
40 '';
41
42 meta.mainProgram = pname;
43 };
44
45in
46stdenv.mkDerivation rec {
47 pname = "keyd";
48 inherit version src;
49
50 postPatch = ''
51 substituteInPlace Makefile \
52 --replace DESTDIR= DESTDIR=${placeholder "out"} \
53 --replace /usr ""
54
55 substituteInPlace keyd.service \
56 --replace /usr/bin $out/bin
57 '';
58
59 buildInputs = [ systemd ];
60
61 enableParallelBuilding = true;
62
63 # post-2.4.2 may need this to unbreak the test
64 # makeFlags = [ "SOCKET_PATH/run/keyd/keyd.socket" ];
65
66 postInstall = ''
67 ln -sf ${lib.getExe appMap} $out/bin/${appMap.pname}
68 rm -rf $out/etc
69 '';
70
71 passthru.tests.keyd = nixosTests.keyd;
72
73 meta = with lib; {
74 description = "A key remapping daemon for linux.";
75 license = licenses.mit;
76 maintainers = with maintainers; [ peterhoeg ];
77 platforms = platforms.linux;
78 };
79}