{ config, lib, pkgs, ... }: { options.custom = with lib; { keyd = { enable = mkEnableOption "Enable keyd"; ids = mkOption { type = types.listOf types.str; default = [ ]; example = [ "0001:0001:70533846" "3434:06a0:d7dfbeabt" "046d:c339:9f276ca6" ]; description = "List of keyboard is that will be configured"; }; }; }; config = lib.mkIf config.custom.keyd.enable { environment.systemPackages = with pkgs; [ keyd ]; users.groups.keyd = { }; services.keyd = let commonSettings = { main = { capslock = "layer(capslock)"; insert = "S-insert"; }; meta = { w = "macro(C-w)"; a = "macro(C-a)"; }; "capslock:C" = { }; }; in { enable = true; keyboards = { default = { ids = [ "*" ]; settings = commonSettings; }; workstation = { ids = config.custom.keyd.ids; settings = lib.mkMerge [ commonSettings { main = { leftalt = "layer(meta)"; leftmeta = "layer(alt)"; }; } ]; }; }; }; systemd.services.keyd.serviceConfig.CapabilityBoundingSet = [ "CAP_SETGID" ]; environment.etc."libinput/local-overrides.quirks".text = '' [Serial Keyboards] MatchUdevType=keyboard MatchName=keyd virtual keyboard AttrKeyboardIntegration=internal ''; }; }