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