diff options
author | xd1le <elisp.vim@gmail.com> | 2017-09-02 16:17:53 +1000 |
---|---|---|
committer | xd1le <elisp.vim@gmail.com> | 2017-09-02 16:17:53 +1000 |
commit | e0b44a09b84ed462b98b2c1fa841253be801ef8c (patch) | |
tree | 11a5c7ca0cfe3f3debb38242660753d28593c9bc /nixos/modules/services | |
parent | 96457d26dded05bcba8e9fbb9bf0255596654aab (diff) | |
download | nixlib-e0b44a09b84ed462b98b2c1fa841253be801ef8c.tar nixlib-e0b44a09b84ed462b98b2c1fa841253be801ef8c.tar.gz nixlib-e0b44a09b84ed462b98b2c1fa841253be801ef8c.tar.bz2 nixlib-e0b44a09b84ed462b98b2c1fa841253be801ef8c.tar.lz nixlib-e0b44a09b84ed462b98b2c1fa841253be801ef8c.tar.xz nixlib-e0b44a09b84ed462b98b2c1fa841253be801ef8c.tar.zst nixlib-e0b44a09b84ed462b98b2c1fa841253be801ef8c.zip |
interception-tools: init at 0.1.1
The latest release of libyamlcpp in nixpkgs does not build because it uses an older version of boost than the one in nixpkgs and therefore expects a particular header file which does not exist in the latest boost anymore. For this reason, a later (git) version of libyamlcpp is used here (which actually doesn't even require boost). The substituteInPlace in the prePatch phase is needed because libevdev places its headers in non-standard places, meaning Nix cannot normally find them. The `cut` command removes the first two "-I" characters from the output of `pkg-config`. This needs to be in the prePatch phase because otherwise Nix will patch these lines to `/var/empty`, meaning you would have less specific replacement (in case other lines are also patched to `/var/empty`). I wrote the patch. (I believe it is NixOS specific.)
Diffstat (limited to 'nixos/modules/services')
-rw-r--r-- | nixos/modules/services/hardware/interception-tools.nix | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/nixos/modules/services/hardware/interception-tools.nix b/nixos/modules/services/hardware/interception-tools.nix new file mode 100644 index 000000000000..fadcb19a016f --- /dev/null +++ b/nixos/modules/services/hardware/interception-tools.nix @@ -0,0 +1,61 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + cfg = config.services.interception-tools; +in { + options.services.interception-tools = { + enable = mkOption { + type = types.bool; + default = false; + description = "Whether to enable the interception tools service."; + }; + + plugins = mkOption { + type = types.listOf types.package; + default = [ pkgs.interception-tools-plugins.caps2esc ]; + description = '' + A list of interception tools plugins that will be made available to use + inside the udevmon configuration. + ''; + }; + + udevmonConfig = mkOption { + type = types.either types.str types.path; + default = '' + - JOB: "intercept -g $DEVNODE | caps2esc | uinput -d $DEVNODE" + DEVICE: + EVENTS: + EV_KEY: [KEY_CAPSLOCK, KEY_ESC] + ''; + example = '' + - JOB: "intercept -g $DEVNODE | y2z | x2y | uinput -d $DEVNODE" + DEVICE: + EVENTS: + EV_KEY: [KEY_X, KEY_Y] + ''; + description = '' + String of udevmon YAML configuration, or path to a udevmon YAML + configuration file. + ''; + }; + }; + + config = mkIf cfg.enable { + systemd.services.interception-tools = { + description = "Interception tools"; + path = [ pkgs.bash pkgs.interception-tools ] ++ cfg.plugins; + serviceConfig = { + ExecStart = '' + ${pkgs.interception-tools}/bin/udevmon -c \ + ${if builtins.typeOf cfg.udevmonConfig == "path" + then cfg.udevmonConfig + else pkgs.writeText "udevmon.yaml" cfg.udevmonConfig} + ''; + Nice = -20; + }; + wantedBy = [ "multi-user.target" ]; + }; + }; +} |