18 buildPythonApplication,
22 # Change the default log level to debug for easier debugging of package issues
23 withDebugLogLevel ? false,
24 # Xmodmap is an optional dependency
25 # If you use Xmodmap to set keyboard mappings (or your DE does)
26 # it is required to correctly map keys
28 # Some tests are flakey under high CPU load and could cause intermittent
29 # failures when building. Override this to true to run tests anyway
30 # See upstream issue: https://github.com/sezanzeb/input-remapper/issues/306
35 maybeXmodmap = lib.optional withXmodmap xmodmap;
37 (buildPythonApplication rec {
38 pname = "input-remapper";
41 src = fetchFromGitHub {
43 repo = "input-remapper";
45 hash = "sha256-rwlVGF/cWSv6Bsvhrs6nMDQ8avYT80aasrhWyQv55/A=";
51 substituteInPlace inputremapper/configs/data.py \
52 --replace "/usr/share" "$out/usr/share"
54 + lib.optionalString withDebugLogLevel ''
56 substituteInPlace inputremapper/logger.py --replace "logger.setLevel(logging.INFO)" "logger.setLevel(logging.DEBUG)"
59 doCheck = withDoCheck;
63 pythonImportsCheck = [
68 # Custom test script, can't use plain pytest / pytestCheckHook
69 # We only run tests in the unit folder, integration tests require UI
70 # To allow tests which access the system and session DBUS to run, we start a dbus session
71 # and bind it to both the system and session buses
72 installCheckPhase = ''
75 <listen>unix:tmpdir=$TMPDIR</listen>
76 <listen>unix:path=/build/system_bus_socket</listen>
77 <standard_session_servicedirs/>
78 <policy context=\"default\">
79 <!-- Allow everything to be sent -->
80 <allow send_destination=\"*\" eavesdrop=\"true\"/>
81 <!-- Allow everything to be received -->
82 <allow eavesdrop=\"true\"/>
83 <!-- Allow anyone to own anything -->
86 </busconfig>" > dbus.cfg
97 DBUS_SYSTEM_BUS_ADDRESS=unix:path=/build/system_bus_socket \
98 ${dbus}/bin/dbus-run-session --config-file dbus.cfg \
99 python tests/test.py --start-dir unit
102 # Nixpkgs 15.9.4.3. When using wrapGAppsHook3 with special derivers you can end up with double wrapped binaries.
103 dontWrapGApps = true;
106 "''${gappsWrapperArgs[@]}"
107 --prefix PATH : "${lib.makeBinPath maybeXmodmap}"
111 nativeBuildInputs = [
113 gettext # needed to build translations
116 gobject-introspection
120 propagatedBuildInputs = [
121 setuptools # needs pkg_resources
131 substituteInPlace data/99-input-remapper.rules \
132 --replace-fail 'RUN+="/bin/input-remapper-control' "RUN+=\"$out/bin/input-remapper-control"
133 substituteInPlace data/input-remapper.service \
134 --replace-fail 'ExecStart=/usr/bin/input-remapper-service' "ExecStart=$out/bin/input-remapper-service"
135 substituteInPlace data/input-remapper-*.desktop \
136 --replace-fail 'Icon=/usr/share/input-remapper/input-remapper.svg' 'Icon=input-remapper.svg'
138 install -m644 -D -t $out/share/applications/ data/*.desktop
139 install -m644 -D -t $out/share/polkit-1/actions/ data/input-remapper.policy
140 install -m644 -D data/99-input-remapper.rules $out/etc/udev/rules.d/99-input-remapper.rules
141 install -m644 -D data/input-remapper.service $out/lib/systemd/system/input-remapper.service
142 install -m644 -D data/input-remapper.policy $out/share/polkit-1/actions/input-remapper.policy
143 install -m644 -D data/inputremapper.Control.conf $out/etc/dbus-1/system.d/inputremapper.Control.conf
144 install -m644 -D data/input-remapper.svg $out/share/icons/hicolor/scalable/apps/input-remapper.svg
145 install -m644 -D -t $out/usr/share/input-remapper/ data/*
147 # Only install input-remapper prefixed binaries, we don't care about deprecated key-mapper ones
148 install -m755 -D -t $out/bin/ bin/input-remapper*
151 passthru.tests = nixosTests.input-remapper;
154 description = "Easy to use tool to change the mapping of your input device buttons";
155 homepage = "https://github.com/sezanzeb/input-remapper";
156 license = licenses.gpl3Plus;
157 platforms = platforms.linux;
158 maintainers = with maintainers; [ LunNova ];
159 mainProgram = "input-remapper-gtk";
164 # Set in an override as buildPythonApplication doesn't yet support
165 # the `final:` arg yet from #119942 'overlay style overridable recursive attributes'
166 # this ensures the rev matches the input src's rev after overriding
167 # See https://discourse.nixos.org/t/avoid-rec-expresions-in-nixpkgs/8293/7 for more
172 # set revision for --version output
173 echo "COMMIT_HASH = '${final.src.rev}'" > inputremapper/commit_hash.py