Commit 46122183 authored by Lin Jian's avatar Lin Jian Committed by pennae
Browse files

nixos/kanata: remove a limit that number of devices cannot be 0

Since 1.0.8, kanata can automatically detect keyboard devices if
linux-dev is not in config.
parent f34917b1
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -8,8 +8,7 @@ let
  keyboard = {
    options = {
      devices = mkOption {
        type = types.addCheck (types.listOf types.str)
          (devices: (length devices) > 0);
        type = types.listOf types.str;
        example = [ "/dev/input/by-id/usb-0000_0000-event-kbd" ];
        description = mdDoc "Paths to keyboard devices.";
      };
@@ -71,12 +70,13 @@ let

  mkName = name: "kanata-${name}";

  mkDevices = devices: concatStringsSep ":" devices;
  mkDevices = devices:
    optionalString ((length devices) > 0) "linux-dev ${concatStringsSep ":" devices}";

  mkConfig = name: keyboard: pkgs.writeText "${mkName name}-config.kdb" ''
    (defcfg
      ${keyboard.extraDefCfg}
      linux-dev ${mkDevices keyboard.devices}
      ${mkDevices keyboard.devices}
      linux-continue-if-no-devs-found yes)

    ${keyboard.config}