git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #155290 from LunNova/input-remapper

input-remapper: init at unstable-2022-02-09 (and add nixos module)

commit9ec2ae338b52a0e4b95274220576129a3bb7a371 authorKevin Cox <kevincox@kevincox.ca> dateTue 15 Feb 2022, 08:24 (5 years ago) parent608688391c7b73
7 files changed+205
maintainers/maintainer-list.nix+6 nixos/doc/manual/from_md/release-notes/rl-2205.section.xml+8 nixos/doc/manual/release-notes/rl-2205.section.md+2 nixos/modules/module-list.nix+1 nixos/modules/services/misc/input-remapper.nix+29 pkgs/tools/inputmethods/input-remapper/default.nix+157 pkgs/top-level/all-packages.nix+2
maintainers/maintainer-list.nix+6
@@ -7110,6 +7110,12 @@
71107110 githubId = 30698906;
71117111 name = "Luna D Dragon";
71127112 };
7113+ LunNova = {
7114+ email = "nixpkgs-maintainer@lunnova.dev";
7115+ github = "LunNova";
7116+ githubId = 782440;
7117+ name = "Luna Nova";
7118+ };
71137119 lionello = {
71147120 email = "lio@lunesu.com";
71157121 github = "lionello";
nixos/doc/manual/from_md/release-notes/rl-2205.section.xml+8
@@ -122,6 +122,14 @@
122122 <link xlink:href="options.html#opt-services.powerdns-admin.enable">services.powerdns-admin</link>.
123123 </para>
124124 </listitem>
125+ <listitem>
126+ <para>
127+ <link xlink:href="https://github.com/sezanzeb/input-remapper">input-remapper</link>,
128+ an easy to use tool to change the mapping of your input device
129+ buttons. Available at
130+ <link xlink:href="options.html#opt-services.input-remapper.enable">services.input-remapper</link>.
131+ </para>
132+ </listitem>
125133 <listitem>
126134 <para>
127135 <link xlink:href="https://invoiceplane.com">InvoicePlane</link>,
nixos/doc/manual/release-notes/rl-2205.section.md+2
@@ -39,6 +39,8 @@ In addition to numerous new and upgraded packages, this release has the followin
3939
4040- [PowerDNS-Admin](https://github.com/ngoduykhanh/PowerDNS-Admin), a web interface for the PowerDNS server. Available at [services.powerdns-admin](options.html#opt-services.powerdns-admin.enable).
4141
42+- [input-remapper](https://github.com/sezanzeb/input-remapper), an easy to use tool to change the mapping of your input device buttons. Available at [services.input-remapper](options.html#opt-services.input-remapper.enable).
43+
4244- [InvoicePlane](https://invoiceplane.com), web application for managing and creating invoices. Available at [services.invoiceplane](options.html#opt-services.invoiceplane.enable).
4345
4446- [maddy](https://maddy.email), a composable all-in-one mail server. Available as [services.maddy](options.html#opt-services.maddy.enable).
nixos/modules/module-list.nix+1
@@ -547,6 +547,7 @@
547547 ./services/misc/greenclip.nix
548548 ./services/misc/home-assistant.nix
549549 ./services/misc/ihaskell.nix
550+ ./services/misc/input-remapper.nix
550551 ./services/misc/irkerd.nix
551552 ./services/misc/jackett.nix
552553 ./services/misc/jellyfin.nix
nixos/modules/services/misc/input-remapper.nixnew file+29
@@ -0,0 +1,29 @@
1+{ pkgs, lib, config, ... }:
2+
3+with lib;
4+
5+let cfg = config.services.input-remapper; in
6+{
7+ options = {
8+ services.input-remapper = {
9+ enable = mkEnableOption "input-remapper, an easy to use tool to change the mapping of your input device buttons.";
10+ package = mkOption {
11+ type = types.package;
12+ default = pkgs.input-remapper;
13+ defaultText = literalExpression "pkgs.input-remapper";
14+ description = ''
15+ The input-remapper package to use.
16+ '';
17+ };
18+ };
19+ };
20+
21+ config = mkIf cfg.enable {
22+ # FIXME: udev rule hangs sometimes when lots of devices connected, so let's not use it
23+ # config.services.udev.packages = mapper-pkg;
24+ services.dbus.packages = cfg.package;
25+ systemd.packages = cfg.package;
26+ environment.systemPackages = cfg.package;
27+ systemd.services.input-remapper.wantedBy = [ "graphical.target" ];
28+ };
29+}
pkgs/tools/inputmethods/input-remapper/default.nixnew file+157
@@ -0,0 +1,157 @@
1+{ lib
2+, python3
3+, pkgconfig
4+, wrapGAppsHook
5+, gettext
6+, gtk3
7+, glib
8+, dbus
9+, gobject-introspection
10+, xmodmap
11+, pygobject3
12+, setuptools
13+, evdev
14+, pydantic
15+, pydbus
16+, psutil
17+, fetchFromGitHub
18+, buildPythonApplication
19+, procps
20+, gtksourceview4
21+ # Change the default log level to debug for easier debugging of package issues
22+, withDebugLogLevel ? false
23+ # Xmodmap is an optional dependency
24+ # If you use Xmodmap to set keyboard mappings (or your DE does)
25+ # it is required to correctly map keys
26+, withXmodmap ? true
27+ # Version and rev and hash are package arguments to allow overriding
28+ # while ensuring the values in prePatch and src match
29+ # https://discourse.nixos.org/t/avoid-rec-expresions-in-nixpkgs/8293/7
30+ # The names are prefixed with input_remapper to avoid potential
31+ # collisions with package names
32+, input_remapper_version ? "unstable-2022-02-09"
33+, input_remapper_src_rev ? "55227e0b5a28d21d7333c6c8ea1c691e56fd35c4"
34+, input_remapper_src_hash ? "sha256-kzGlEaYN/JfAgbI0aMLr5mwObYOL43X7QU/ihDEBQFg="
35+}:
36+
37+let
38+ maybeXmodmap = lib.optional withXmodmap xmodmap;
39+in
40+buildPythonApplication {
41+ pname = "input-remapper";
42+ version = input_remapper_version;
43+
44+ src = fetchFromGitHub {
45+ rev = input_remapper_src_rev;
46+ owner = "sezanzeb";
47+ repo = "input-remapper";
48+ hash = input_remapper_src_hash;
49+ };
50+
51+ # Fixes error
52+ # Couldn’t recognize the image file format for file "*.svg"
53+ # at startup, see https://github.com/NixOS/nixpkgs/issues/56943
54+ strictDeps = false;
55+
56+ prePatch = ''
57+ # set revision for --version output
58+ echo "COMMIT_HASH = '${input_remapper_src_rev}'" > inputremapper/commit_hash.py
59+
60+ # fix FHS paths
61+ substituteInPlace inputremapper/configs/data.py \
62+ --replace "/usr/share/input-remapper" "$out/usr/share/input-remapper"
63+ '' + (lib.optionalString (withDebugLogLevel) ''
64+ # if debugging
65+ substituteInPlace inputremapper/logger.py --replace "logger.setLevel(logging.INFO)" "logger.setLevel(logging.DEBUG)"
66+ '');
67+
68+ doCheck = true;
69+ checkInputs = [
70+ psutil
71+ ];
72+ pythonImportsCheck = [
73+ "evdev"
74+ "inputremapper"
75+ ];
76+
77+ # Custom test script, can't use plain pytest / pytestCheckHook
78+ # We only run tests in the unit folder, integration tests require UI
79+ # To allow tests which access the system and session DBUS to run, we start a dbus session
80+ # and bind it to both the system and session buses
81+ installCheckPhase = ''
82+ echo "<busconfig>
83+ <type>session</type>
84+ <listen>unix:tmpdir=$TMPDIR</listen>
85+ <listen>unix:path=/build/system_bus_socket</listen>
86+ <standard_session_servicedirs/>
87+ <policy context=\"default\">
88+ <!-- Allow everything to be sent -->
89+ <allow send_destination=\"*\" eavesdrop=\"true\"/>
90+ <!-- Allow everything to be received -->
91+ <allow eavesdrop=\"true\"/>
92+ <!-- Allow anyone to own anything -->
93+ <allow own=\"*\"/>
94+ </policy>
95+ </busconfig>" > dbus.cfg
96+ PATH=${lib.makeBinPath ([ dbus procps ] ++ maybeXmodmap)}:$PATH \
97+ USER="$(id -u -n)" \
98+ DBUS_SYSTEM_BUS_ADDRESS=unix:path=/build/system_bus_socket \
99+ ${dbus}/bin/dbus-run-session --config-file dbus.cfg \
100+ python tests/test.py --start-dir unit
101+ '';
102+
103+ # Nixpkgs 15.9.4.3. When using wrapGAppsHook with special derivers you can end up with double wrapped binaries.
104+ dontWrapGApps = true;
105+ preFixup = ''
106+ makeWrapperArgs+=(
107+ "''${gappsWrapperArgs[@]}"
108+ --prefix PATH : "${lib.makeBinPath maybeXmodmap}"
109+ )
110+ '';
111+
112+ nativeBuildInputs = [
113+ wrapGAppsHook
114+ gettext # needed to build translations
115+ gtk3
116+ glib
117+ gobject-introspection
118+ pygobject3
119+ ] ++ maybeXmodmap;
120+
121+ propagatedBuildInputs = [
122+ setuptools # needs pkg_resources
123+ pygobject3
124+ evdev
125+ pkgconfig
126+ pydantic
127+ pydbus
128+ gtksourceview4
129+ ];
130+
131+ postInstall = ''
132+ sed -r "s#RUN\+\=\"/bin/input-remapper-control#RUN\+\=\"$out/bin/input-remapper-control#g" -i data/99-input-remapper.rules
133+ sed -r "s#ExecStart\=/usr/bin/input-remapper-service#ExecStart\=$out/bin/input-remapper-service#g" -i data/input-remapper.service
134+
135+ chmod +x data/*.desktop
136+
137+ install -D -t $out/share/applications/ data/*.desktop
138+ install -D -t $out/share/polkit-1/actions/ data/input-remapper.policy
139+ install -D data/99-input-remapper.rules $out/etc/udev/rules.d/99-input-remapper.rules
140+ install -D data/input-remapper.service $out/lib/systemd/system/input-remapper.service
141+ install -D data/input-remapper.policy $out/share/polkit-1/actions/input-remapper.policy
142+ install -D data/inputremapper.Control.conf $out/etc/dbus-1/system.d/inputremapper.Control.conf
143+ install -D -t $out/usr/share/input-remapper/ data/*
144+
145+ # Only install input-remapper prefixed binaries, we don't care about deprecated key-mapper ones
146+ install -m755 -D -t $out/bin/ bin/input-remapper*
147+ '';
148+
149+ meta = with lib; {
150+ description = "An easy to use tool to change the mapping of your input device buttons";
151+ homepage = "https://github.com/sezanzeb/input-remapper";
152+ license = licenses.gpl3Plus;
153+ platforms = platforms.linux;
154+ maintainers = with maintainers; [ LunNova ];
155+ mainProgram = "input-remapper-gtk";
156+ };
157+}
pkgs/top-level/all-packages.nix+2
@@ -6633,6 +6633,8 @@ with pkgs;
66336633
66346634 innoextract = callPackage ../tools/archivers/innoextract { };
66356635
6636+ input-remapper = python3Packages.callPackage ../tools/inputmethods/input-remapper { };
6637+
66366638 input-utils = callPackage ../os-specific/linux/input-utils { };
66376639
66386640 inql = callPackage ../tools/security/inql { };