Skip to content

Commit

Permalink
nixos/kmonad: avoid running an unnecessary bash
Browse files Browse the repository at this point in the history
  • Loading branch information
jian-lin committed Jan 2, 2025
1 parent ed3f112 commit c3588cf
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
14 changes: 5 additions & 9 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,17 +119,8 @@ let
# Build a systemd service that starts KMonad:
mkService =
keyboard:
let
cmd =
[
(lib.getExe cfg.package)
]
++ 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 @@ -137,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 c3588cf

Please sign in to comment.