keyd: properly handle the python script

This commit is contained in:
Peter Hoeg 2022-09-07 17:35:04 +08:00
parent a3ec78e8d6
commit 0b5aca8a88

View file

@ -4,10 +4,11 @@
, cmake , cmake
, pkg-config , pkg-config
, systemd , systemd
, runtimeShell
, python3
}: }:
stdenv.mkDerivation rec { let
pname = "keyd";
version = "2.4.2"; version = "2.4.2";
src = fetchFromGitHub { src = fetchFromGitHub {
@ -17,11 +18,38 @@ stdenv.mkDerivation rec {
hash = "sha256-QWr+xog16MmybhQlEWbskYa/dypb9Ld54MOdobTbyMo="; hash = "sha256-QWr+xog16MmybhQlEWbskYa/dypb9Ld54MOdobTbyMo=";
}; };
pypkgs = python3.pkgs;
appMap = pypkgs.buildPythonApplication rec {
pname = "keyd-application-mapper";
inherit version src;
format = "other";
postPatch = ''
substituteInPlace scripts/${pname} \
--replace /bin/sh ${runtimeShell}
'';
propagatedBuildInputs = with pypkgs; [ xlib ];
dontBuild = true;
installPhase = ''
install -Dm555 -t $out/bin scripts/${pname}
'';
meta.mainProgram = pname;
};
in
stdenv.mkDerivation rec {
pname = "keyd";
inherit version src;
postPatch = '' postPatch = ''
substituteInPlace Makefile \ substituteInPlace Makefile \
--replace DESTDIR= DESTDIR=${placeholder "out"} \ --replace DESTDIR= DESTDIR=${placeholder "out"} \
--replace /usr "" \ --replace /usr ""
--replace /var/log/keyd.log /var/log/keyd/keyd.log
substituteInPlace keyd.service \ substituteInPlace keyd.service \
--replace /usr/bin $out/bin --replace /usr/bin $out/bin
@ -32,6 +60,7 @@ stdenv.mkDerivation rec {
enableParallelBuilding = true; enableParallelBuilding = true;
postInstall = '' postInstall = ''
ln -sf ${lib.getExe appMap} $out/bin/${appMap.pname}
rm -rf $out/etc rm -rf $out/etc
''; '';