mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-11-10 17:54:53 +01:00
After final improvements to the official formatter implementation,
this commit now performs the first treewide reformat of Nix files using it.
This is part of the implementation of RFC 166.
Only "inactive" files are reformatted, meaning only files that
aren't being touched by any PR with activity in the past 2 months.
This is to avoid conflicts for PRs that might soon be merged.
Later we can do a full treewide reformat to get the rest,
which should not cause as many conflicts.
A CI check has already been running for some time to ensure that new and
already-formatted files are formatted, so the files being reformatted here
should also stay formatted.
This commit was automatically created and can be verified using
nix-build a08b3a4d19.tar.gz \
--argstr baseRev b32a094368
result/bin/apply-formatting $NIXPKGS_PATH
152 lines
3.5 KiB
Nix
152 lines
3.5 KiB
Nix
{
|
|
config,
|
|
lib,
|
|
pkgs,
|
|
...
|
|
}:
|
|
let
|
|
|
|
cfg = config.services.actkbd;
|
|
|
|
configFile = pkgs.writeText "actkbd.conf" ''
|
|
${lib.concatMapStringsSep "\n" (
|
|
{
|
|
keys,
|
|
events,
|
|
attributes,
|
|
command,
|
|
...
|
|
}:
|
|
''${
|
|
lib.concatMapStringsSep "+" toString keys
|
|
}:${lib.concatStringsSep "," events}:${lib.concatStringsSep "," attributes}:${command}''
|
|
) cfg.bindings}
|
|
${cfg.extraConfig}
|
|
'';
|
|
|
|
bindingCfg =
|
|
{ ... }:
|
|
{
|
|
options = {
|
|
|
|
keys = lib.mkOption {
|
|
type = lib.types.listOf lib.types.int;
|
|
description = "List of keycodes to match.";
|
|
};
|
|
|
|
events = lib.mkOption {
|
|
type = lib.types.listOf (
|
|
lib.types.enum [
|
|
"key"
|
|
"rep"
|
|
"rel"
|
|
]
|
|
);
|
|
default = [ "key" ];
|
|
description = "List of events to match.";
|
|
};
|
|
|
|
attributes = lib.mkOption {
|
|
type = lib.types.listOf lib.types.str;
|
|
default = [ "exec" ];
|
|
description = "List of attributes.";
|
|
};
|
|
|
|
command = lib.mkOption {
|
|
type = lib.types.str;
|
|
default = "";
|
|
description = "What to run.";
|
|
};
|
|
|
|
};
|
|
};
|
|
|
|
in
|
|
|
|
{
|
|
|
|
###### interface
|
|
|
|
options = {
|
|
|
|
services.actkbd = {
|
|
|
|
enable = lib.mkOption {
|
|
type = lib.types.bool;
|
|
default = false;
|
|
description = ''
|
|
Whether to enable the {command}`actkbd` key mapping daemon.
|
|
|
|
Turning this on will start an {command}`actkbd`
|
|
instance for every evdev input that has at least one key
|
|
(which is okay even for systems with tiny memory footprint,
|
|
since actkbd normally uses \<100 bytes of memory per
|
|
instance).
|
|
|
|
This allows binding keys globally without the need for e.g.
|
|
X11.
|
|
'';
|
|
};
|
|
|
|
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"; }
|
|
]
|
|
'';
|
|
description = ''
|
|
Key bindings for {command}`actkbd`.
|
|
|
|
See {command}`actkbd` {file}`README` for documentation.
|
|
|
|
The example shows a piece of what {option}`sound.mediaKeys.enable` does when enabled.
|
|
'';
|
|
};
|
|
|
|
extraConfig = lib.mkOption {
|
|
type = lib.types.lines;
|
|
default = "";
|
|
description = ''
|
|
Literal contents to append to the end of actkbd configuration file.
|
|
'';
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
###### implementation
|
|
|
|
config = lib.mkIf cfg.enable {
|
|
|
|
services.udev.packages = lib.singleton (
|
|
pkgs.writeTextFile {
|
|
name = "actkbd-udev-rules";
|
|
destination = "/etc/udev/rules.d/61-actkbd.rules";
|
|
text = ''
|
|
ACTION=="add", SUBSYSTEM=="input", KERNEL=="event[0-9]*", ENV{ID_INPUT_KEY}=="1", TAG+="systemd", ENV{SYSTEMD_WANTS}+="actkbd@$env{DEVNAME}.service"
|
|
'';
|
|
}
|
|
);
|
|
|
|
systemd.services."actkbd@" = {
|
|
enable = true;
|
|
restartIfChanged = true;
|
|
unitConfig = {
|
|
Description = "actkbd on %I";
|
|
ConditionPathExists = "%I";
|
|
};
|
|
serviceConfig = {
|
|
Type = "forking";
|
|
ExecStart = "${pkgs.actkbd}/bin/actkbd -D -c ${configFile} -d %I";
|
|
};
|
|
};
|
|
|
|
# For testing
|
|
environment.systemPackages = [ pkgs.actkbd ];
|
|
|
|
};
|
|
|
|
}
|