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