Skip to content

Commit

Permalink
nixos/kmonad: avoid running an unnecessary bash (#370064)
Browse files Browse the repository at this point in the history
  • Loading branch information
jian-lin authored Jan 2, 2025
2 parents e36ab94 + c3588cf commit aff999e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
16 changes: 5 additions & 11 deletions nixos/modules/services/hardware/kmonad.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
config,
lib,
pkgs,
utils,
...
}:

Expand Down Expand Up @@ -118,19 +119,8 @@ let
# Build a systemd service that starts KMonad:
mkService =
keyboard:
let
cmd =
[
(lib.getExe cfg.package)
"--input"
''device-file "${keyboard.device}"''
]
++ cfg.extraArgs
++ [ "${mkCfg keyboard}" ];
in
lib.nameValuePair (mkName keyboard.name) {
description = "KMonad for ${keyboard.device}";
script = lib.escapeShellArgs cmd;
unitConfig = {
# Control rate limiting.
# Stop the restart logic if we restart more than
Expand All @@ -139,6 +129,10 @@ let
StartLimitBurst = 5;
};
serviceConfig = {
ExecStart = ''
${lib.getExe cfg.package} ${mkCfg keyboard} \
${utils.escapeSystemdExecArgs cfg.extraArgs}
'';
Restart = "always";
# Restart at increasing intervals from 2s to 1m
RestartSec = 2;
Expand Down
3 changes: 3 additions & 0 deletions nixos/tests/kmonad.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
machine = {
services.kmonad = {
enable = true;
extraArgs = [
"--log-level=debug"
];
keyboards = {
defaultKbd = {
device = "/dev/input/by-id/vm-default-kbd";
Expand Down

0 comments on commit aff999e

Please sign in to comment.