diff options
author | Alyssa Ross <hi@alyssa.is> | 2022-02-22 10:43:06 +0000 |
---|---|---|
committer | Alyssa Ross <hi@alyssa.is> | 2022-03-11 16:17:56 +0000 |
commit | ca1aada113c0ebda1ab8667199f6453f8e01c4fc (patch) | |
tree | 55e402280096f62eb0bc8bcad5ce6050c5a0aec7 /nixpkgs/pkgs/tools/inputmethods/input-remapper | |
parent | e4df5a52a6a6531f32626f57205356a773ac2975 (diff) | |
parent | 93883402a445ad467320925a0a5dbe43a949f25b (diff) | |
download | nixlib-ca1aada113c0ebda1ab8667199f6453f8e01c4fc.tar nixlib-ca1aada113c0ebda1ab8667199f6453f8e01c4fc.tar.gz nixlib-ca1aada113c0ebda1ab8667199f6453f8e01c4fc.tar.bz2 nixlib-ca1aada113c0ebda1ab8667199f6453f8e01c4fc.tar.lz nixlib-ca1aada113c0ebda1ab8667199f6453f8e01c4fc.tar.xz nixlib-ca1aada113c0ebda1ab8667199f6453f8e01c4fc.tar.zst nixlib-ca1aada113c0ebda1ab8667199f6453f8e01c4fc.zip |
Merge commit '93883402a445ad467320925a0a5dbe43a949f25b'
Conflicts: nixpkgs/nixos/modules/programs/ssh.nix nixpkgs/pkgs/applications/networking/browsers/firefox/packages.nix nixpkgs/pkgs/data/fonts/noto-fonts/default.nix nixpkgs/pkgs/development/go-modules/generic/default.nix nixpkgs/pkgs/development/interpreters/ruby/default.nix nixpkgs/pkgs/development/libraries/mesa/default.nix
Diffstat (limited to 'nixpkgs/pkgs/tools/inputmethods/input-remapper')
-rw-r--r-- | nixpkgs/pkgs/tools/inputmethods/input-remapper/default.nix | 157 |
1 files changed, 157 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/tools/inputmethods/input-remapper/default.nix b/nixpkgs/pkgs/tools/inputmethods/input-remapper/default.nix new file mode 100644 index 000000000000..82664c3700e2 --- /dev/null +++ b/nixpkgs/pkgs/tools/inputmethods/input-remapper/default.nix @@ -0,0 +1,157 @@ +{ lib +, python3 +, pkgconfig +, wrapGAppsHook +, gettext +, gtk3 +, glib +, dbus +, gobject-introspection +, xmodmap +, pygobject3 +, setuptools +, evdev +, pydantic +, pydbus +, psutil +, fetchFromGitHub +, buildPythonApplication +, procps +, gtksourceview4 + # Change the default log level to debug for easier debugging of package issues +, withDebugLogLevel ? false + # Xmodmap is an optional dependency + # If you use Xmodmap to set keyboard mappings (or your DE does) + # it is required to correctly map keys +, withXmodmap ? true + # Version and rev and hash are package arguments to allow overriding + # while ensuring the values in prePatch and src match + # https://discourse.nixos.org/t/avoid-rec-expresions-in-nixpkgs/8293/7 + # The names are prefixed with input_remapper to avoid potential + # collisions with package names +, input_remapper_version ? "unstable-2022-02-09" +, input_remapper_src_rev ? "55227e0b5a28d21d7333c6c8ea1c691e56fd35c4" +, input_remapper_src_hash ? "sha256-kzGlEaYN/JfAgbI0aMLr5mwObYOL43X7QU/ihDEBQFg=" +}: + +let + maybeXmodmap = lib.optional withXmodmap xmodmap; +in +buildPythonApplication { + pname = "input-remapper"; + version = input_remapper_version; + + src = fetchFromGitHub { + rev = input_remapper_src_rev; + owner = "sezanzeb"; + repo = "input-remapper"; + hash = input_remapper_src_hash; + }; + + # Fixes error + # Couldn’t recognize the image file format for file "*.svg" + # at startup, see https://github.com/NixOS/nixpkgs/issues/56943 + strictDeps = false; + + prePatch = '' + # set revision for --version output + echo "COMMIT_HASH = '${input_remapper_src_rev}'" > inputremapper/commit_hash.py + + # fix FHS paths + substituteInPlace inputremapper/configs/data.py \ + --replace "/usr/share/input-remapper" "$out/usr/share/input-remapper" + '' + (lib.optionalString (withDebugLogLevel) '' + # if debugging + substituteInPlace inputremapper/logger.py --replace "logger.setLevel(logging.INFO)" "logger.setLevel(logging.DEBUG)" + ''); + + doCheck = true; + checkInputs = [ + psutil + ]; + pythonImportsCheck = [ + "evdev" + "inputremapper" + ]; + + # Custom test script, can't use plain pytest / pytestCheckHook + # We only run tests in the unit folder, integration tests require UI + # To allow tests which access the system and session DBUS to run, we start a dbus session + # and bind it to both the system and session buses + installCheckPhase = '' + echo "<busconfig> + <type>session</type> + <listen>unix:tmpdir=$TMPDIR</listen> + <listen>unix:path=/build/system_bus_socket</listen> + <standard_session_servicedirs/> + <policy context=\"default\"> + <!-- Allow everything to be sent --> + <allow send_destination=\"*\" eavesdrop=\"true\"/> + <!-- Allow everything to be received --> + <allow eavesdrop=\"true\"/> + <!-- Allow anyone to own anything --> + <allow own=\"*\"/> + </policy> + </busconfig>" > dbus.cfg + PATH=${lib.makeBinPath ([ dbus procps ] ++ maybeXmodmap)}:$PATH \ + USER="$(id -u -n)" \ + DBUS_SYSTEM_BUS_ADDRESS=unix:path=/build/system_bus_socket \ + ${dbus}/bin/dbus-run-session --config-file dbus.cfg \ + python tests/test.py --start-dir unit + ''; + + # Nixpkgs 15.9.4.3. When using wrapGAppsHook with special derivers you can end up with double wrapped binaries. + dontWrapGApps = true; + preFixup = '' + makeWrapperArgs+=( + "''${gappsWrapperArgs[@]}" + --prefix PATH : "${lib.makeBinPath maybeXmodmap}" + ) + ''; + + nativeBuildInputs = [ + wrapGAppsHook + gettext # needed to build translations + gtk3 + glib + gobject-introspection + pygobject3 + ] ++ maybeXmodmap; + + propagatedBuildInputs = [ + setuptools # needs pkg_resources + pygobject3 + evdev + pkgconfig + pydantic + pydbus + gtksourceview4 + ]; + + postInstall = '' + sed -r "s#RUN\+\=\"/bin/input-remapper-control#RUN\+\=\"$out/bin/input-remapper-control#g" -i data/99-input-remapper.rules + sed -r "s#ExecStart\=/usr/bin/input-remapper-service#ExecStart\=$out/bin/input-remapper-service#g" -i data/input-remapper.service + + chmod +x data/*.desktop + + install -D -t $out/share/applications/ data/*.desktop + install -D -t $out/share/polkit-1/actions/ data/input-remapper.policy + install -D data/99-input-remapper.rules $out/etc/udev/rules.d/99-input-remapper.rules + install -D data/input-remapper.service $out/lib/systemd/system/input-remapper.service + install -D data/input-remapper.policy $out/share/polkit-1/actions/input-remapper.policy + install -D data/inputremapper.Control.conf $out/etc/dbus-1/system.d/inputremapper.Control.conf + install -D -t $out/usr/share/input-remapper/ data/* + + # Only install input-remapper prefixed binaries, we don't care about deprecated key-mapper ones + install -m755 -D -t $out/bin/ bin/input-remapper* + ''; + + meta = with lib; { + description = "An easy to use tool to change the mapping of your input device buttons"; + homepage = "https://github.com/sezanzeb/input-remapper"; + license = licenses.gpl3Plus; + platforms = platforms.linux; + maintainers = with maintainers; [ LunNova ]; + mainProgram = "input-remapper-gtk"; + }; +} |