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

76 lines
2.1 KiB
Nix
Raw Normal View History

2021-09-06 13:43:55 +00:00
{
pkgs, lib
, python3Packages, python3
, gtk3, gobject-introspection, git, gnome
, wrapGAppsHook
, makeDesktopItem
2021-11-01 21:12:21 +00:00
, fetchFromGitHub
2021-09-06 13:43:55 +00:00
}:
python3Packages.buildPythonApplication rec {
pname = "key-mapper";
2021-11-01 21:12:21 +00:00
# TODO: Update to 1.2.1
version = "1.0.0";
buildInputs = [ gobject-introspection gtk3 gnome.adwaita-icon-theme ];
nativeBuildInputs = [ wrapGAppsHook ];
propagatedBuildInputs = with python3.pkgs; [ setuptools pydbus evdev pygobject3 ];
2021-11-01 21:12:21 +00:00
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
'';
2021-09-06 13:43:55 +00:00
postInstall = ''
2021-10-18 14:07:55 +00:00
# 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
2021-09-06 13:43:55 +00:00
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";
2021-09-06 13:43:55 +00:00
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;
};
}