Skip to content

Commit

Permalink
nixos/services.actkbd: remove with lib;
Browse files Browse the repository at this point in the history
  • Loading branch information
Stunkymonkey committed Dec 8, 2024
1 parent ae5e538 commit e7095ad
Showing 1 changed file with 17 additions and 20 deletions.
37 changes: 17 additions & 20 deletions nixos/modules/services/hardware/actkbd.nix
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
{ config, lib, pkgs, ... }:

with lib;

let

cfg = config.services.actkbd;

configFile = pkgs.writeText "actkbd.conf" ''
${concatMapStringsSep "\n"
${lib.concatMapStringsSep "\n"
({ keys, events, attributes, command, ... }:
''${concatMapStringsSep "+" toString keys}:${concatStringsSep "," events}:${concatStringsSep "," attributes}:${command}''
''${lib.concatMapStringsSep "+" toString keys}:${lib.concatStringsSep "," events}:${lib.concatStringsSep "," attributes}:${command}''
)
cfg.bindings}
${cfg.extraConfig}
Expand All @@ -18,25 +15,25 @@ let
bindingCfg = { ... }: {
options = {

keys = mkOption {
type = types.listOf types.int;
keys = lib.mkOption {
type = lib.types.listOf lib.types.int;
description = "List of keycodes to match.";
};

events = mkOption {
type = types.listOf (types.enum ["key" "rep" "rel"]);
events = lib.mkOption {
type = lib.types.listOf (lib.types.enum ["key" "rep" "rel"]);
default = [ "key" ];
description = "List of events to match.";
};

attributes = mkOption {
type = types.listOf types.str;
attributes = lib.mkOption {
type = lib.types.listOf lib.types.str;
default = [ "exec" ];
description = "List of attributes.";
};

command = mkOption {
type = types.str;
command = lib.mkOption {
type = lib.types.str;
default = "";
description = "What to run.";
};
Expand All @@ -54,8 +51,8 @@ in

services.actkbd = {

enable = mkOption {
type = types.bool;
enable = lib.mkOption {
type = lib.types.bool;
default = false;
description = ''
Whether to enable the {command}`actkbd` key mapping daemon.
Expand All @@ -71,8 +68,8 @@ in
'';
};

bindings = mkOption {
type = types.listOf (types.submodule bindingCfg);
bindings = lib.mkOption {
type = lib.types.listOf (lib.types.submodule bindingCfg);
default = [];
example = lib.literalExpression ''
[ { keys = [ 113 ]; events = [ "key" ]; command = "''${pkgs.alsa-utils}/bin/amixer -q set Master toggle"; }
Expand All @@ -87,8 +84,8 @@ in
'';
};

extraConfig = mkOption {
type = types.lines;
extraConfig = lib.mkOption {
type = lib.types.lines;
default = "";
description = ''
Literal contents to append to the end of actkbd configuration file.
Expand All @@ -102,7 +99,7 @@ in

###### implementation

config = mkIf cfg.enable {
config = lib.mkIf cfg.enable {

services.udev.packages = lib.singleton (pkgs.writeTextFile {
name = "actkbd-udev-rules";
Expand Down

0 comments on commit e7095ad

Please sign in to comment.