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

72 lines
2.0 KiB
Nix

{
pkgs, lib
, python3Packages, python3
, gtk3, gobject-introspection, git, gnome
, wrapGAppsHook
, makeDesktopItem
}:
python3Packages.buildPythonApplication rec {
pname = "key-mapper";
version = "1.0.0";
buildInputs = [ gobject-introspection gtk3 gnome.adwaita-icon-theme ];
nativeBuildInputs = [ wrapGAppsHook ];
propagatedBuildInputs = with python3.pkgs; [ setuptools pydbus evdev pygobject3 ];
src = builtins.fetchGit {
url = "https://github.com/sezanzeb/key-mapper.git";
ref = version;
};
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;
};
}