nixos-config/packages/tools/games/key-mapper/default.nix

75 lines
2.0 KiB
Nix

{
pkgs, lib
, python3Packages, python3
, gtk3, gobject-introspection, git, gnome
, wrapGAppsHook
, makeDesktopItem
, fetchFromGitHub
}:
python3Packages.buildPythonApplication rec {
pname = "key-mapper";
version = "1.2.1";
buildInputs = [ gobject-introspection gtk3 gnome.adwaita-icon-theme ];
nativeBuildInputs = [ wrapGAppsHook ];
propagatedBuildInputs = with python3.pkgs; [ setuptools pydbus evdev pygobject3 ];
src = fetchFromGitHub {
owner = "sezanzeb";
repo = "key-mapper";
rev = version;
sha256 = "07dgp4vays1w4chhd22vlp9bxc49lcgzkvmjqgbr00m3781yjsf7";
};
doCheck = false;
strictDeps = false;
patches = [
./add-scripts.patch
./hack-data-dir.patch
];
# Fix keymapper not finding its data files
preBuild = ''
sed -e "s|@@NIXOS_OUT_PATH@@|$out/usr/share/key-mapper|" --in-place keymapper/data.py
'';
# Required as we otherwise don't get the dbus policy installed
# correctly
preInstall = ''
# see https://github.com/pypa/setuptools/issues/130
${python3}/bin/${python3.executable} setup.py install_data --install-dir=$out --root=$out
'';
postInstall = ''
# Install the udev rules
mkdir -p $out/lib/udev/rules.d
cp data/key-mapper.rules $out/lib/udev/rules.d/key-mapper.rules
sed --in-place -e "s|/bin/key-mapper-control|$out/bin/key-mapper-control|" $out/lib/udev/rules.d/key-mapper.rules
# Install the desktop file
mkdir -p $out/share/icons/hicolor/scalable/apps/
cp -r ${desktopItem}/share/applications $out/share/
cp $out/usr/share/key-mapper/key-mapper.svg $out/share/icons/hicolor/scalable/apps/key-mapper.svg
'';
desktopItem = makeDesktopItem {
name = "key-mapper";
exec = "key-mapper-gtk";
icon = "key-mapper";
desktopName = "key-mapper";
genericName = "key-mapper";
};
meta = with lib; {
homepage = "https://github.com/sezanzeb/key-mapper";
description = "A tool to change the mapping of your input device buttons";
license = licenses.gpl3;
maintainers = [ ];
platforms = lib.platforms.linux;
};
}