From ed3f112a0e6bafe629f602fd7b1e313ed1a57ad6 Mon Sep 17 00:00:00 2001 From: Lin Jian Date: Thu, 2 Jan 2025 06:11:49 +0800 Subject: [PATCH 1/2] nixos/kmonad: remove unnecessary cli flag --input input has already been set in the config file. --- nixos/modules/services/hardware/kmonad.nix | 2 -- 1 file changed, 2 deletions(-) diff --git a/nixos/modules/services/hardware/kmonad.nix b/nixos/modules/services/hardware/kmonad.nix index 687224fae2e92..86e9e32012cf1 100644 --- a/nixos/modules/services/hardware/kmonad.nix +++ b/nixos/modules/services/hardware/kmonad.nix @@ -122,8 +122,6 @@ let cmd = [ (lib.getExe cfg.package) - "--input" - ''device-file "${keyboard.device}"'' ] ++ cfg.extraArgs ++ [ "${mkCfg keyboard}" ]; From c3588cf2c5fb41bb1759fd0b46820384625c8120 Mon Sep 17 00:00:00 2001 From: Lin Jian Date: Thu, 2 Jan 2025 06:42:32 +0800 Subject: [PATCH 2/2] nixos/kmonad: avoid running an unnecessary bash --- nixos/modules/services/hardware/kmonad.nix | 14 +++++--------- nixos/tests/kmonad.nix | 3 +++ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/nixos/modules/services/hardware/kmonad.nix b/nixos/modules/services/hardware/kmonad.nix index 86e9e32012cf1..df60f07d3890f 100644 --- a/nixos/modules/services/hardware/kmonad.nix +++ b/nixos/modules/services/hardware/kmonad.nix @@ -2,6 +2,7 @@ config, lib, pkgs, + utils, ... }: @@ -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 @@ -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; diff --git a/nixos/tests/kmonad.nix b/nixos/tests/kmonad.nix index e0150cb99f183..57bb9249397c2 100644 --- a/nixos/tests/kmonad.nix +++ b/nixos/tests/kmonad.nix @@ -11,6 +11,9 @@ machine = { services.kmonad = { enable = true; + extraArgs = [ + "--log-level=debug" + ]; keyboards = { defaultKbd = { device = "/dev/input/by-id/vm-default-kbd";