{ pkgs, lib , python3Packages, python3 , gtk3, gobject-introspection, git, gnome, gtksourceview4 , wrapGAppsHook , makeDesktopItem , fetchFromGitHub }: python3Packages.buildPythonApplication rec { pname = "input-remapper"; version = "1.4.0"; buildInputs = [ gobject-introspection gtk3 gnome.adwaita-icon-theme gtksourceview4 ]; nativeBuildInputs = [ wrapGAppsHook ]; propagatedBuildInputs = with python3.pkgs; [ setuptools pydbus evdev pygobject3 ]; src = fetchFromGitHub { owner = "sezanzeb"; repo = "input-remapper"; rev = version; sha256 = "0h64cblpfz2zk15r2ja1kww1cw54gywmfr1zc16qx7sbjy0yi8px"; }; doCheck = false; strictDeps = false; patches = [ ./add-scripts.patch ./hack-data-dir.patch ]; # Fix input-remapper not finding its data files preBuild = '' sed -e "s|@@NIXOS_OUT_PATH@@|$out/usr/share/input-remapper|" --in-place inputremapper/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/99-input-remapper.rules $out/lib/udev/rules.d/99-input-remapper.rules sed --in-place -e "s|/bin/input-remapper-control|$out/bin/input-remapper-control|" $out/lib/udev/rules.d/99-input-remapper.rules # Install the desktop file mkdir -p $out/share/icons/hicolor/scalable/apps/ cp -r ${desktopItem}/share/applications $out/share/ cp $out/usr/share/input-remapper/input-remapper.svg $out/share/icons/hicolor/scalable/apps/input-remapper.svg ''; desktopItem = makeDesktopItem { name = "input-remapper"; exec = "input-remapper-gtk"; icon = "input-remapper"; desktopName = "input-remapper"; genericName = "input-remapper"; }; meta = with lib; { homepage = "https://github.com/sezanzeb/input-remapper"; description = "A tool to change the mapping of your input device buttons"; license = licenses.gpl3; maintainers = [ ]; platforms = lib.platforms.linux; }; }