From 09312ef3d34b382d97462d25f164c0787cd290b1 Mon Sep 17 00:00:00 2001 From: Mariano Uvalle Date: Mon, 4 Aug 2025 20:04:54 -0700 Subject: [PATCH] [macbook] install karabiner through nix. Signed-off-by: Mariano Uvalle --- .../explicit-configs/karabiner/karabiner.json | 288 ++++++++++++++++++ home-modules/karabiner.nix | 5 + hosts/macbook/configuration.nix | 1 + hosts/macbook/home.nix | 12 +- 4 files changed, 300 insertions(+), 6 deletions(-) create mode 100644 home-modules/explicit-configs/karabiner/karabiner.json create mode 100644 home-modules/karabiner.nix diff --git a/home-modules/explicit-configs/karabiner/karabiner.json b/home-modules/explicit-configs/karabiner/karabiner.json new file mode 100644 index 0000000..6b80c94 --- /dev/null +++ b/home-modules/explicit-configs/karabiner/karabiner.json @@ -0,0 +1,288 @@ +{ + "profiles": [ + { + "devices": [ + { + "identifiers": { "is_keyboard": true }, + "simple_modifications": [ + { + "from": { "key_code": "b" }, + "to": [{ "key_code": "v" }] + }, + { + "from": { "key_code": "caps_lock" }, + "to": [{ "key_code": "left_control" }] + }, + { + "from": { "key_code": "d" }, + "to": [{ "key_code": "s" }] + }, + { + "from": { "key_code": "e" }, + "to": [{ "key_code": "f" }] + }, + { + "from": { "key_code": "f" }, + "to": [{ "key_code": "t" }] + }, + { + "from": { "key_code": "h" }, + "to": [{ "key_code": "m" }] + }, + { + "from": { "key_code": "i" }, + "to": [{ "key_code": "u" }] + }, + { + "from": { "key_code": "j" }, + "to": [{ "key_code": "n" }] + }, + { + "from": { "key_code": "k" }, + "to": [{ "key_code": "e" }] + }, + { + "from": { "key_code": "l" }, + "to": [{ "key_code": "i" }] + }, + { + "from": { "key_code": "m" }, + "to": [{ "key_code": "h" }] + }, + { + "from": { "key_code": "n" }, + "to": [{ "key_code": "k" }] + }, + { + "from": { "key_code": "o" }, + "to": [{ "key_code": "y" }] + }, + { + "from": { "key_code": "p" }, + "to": [{ "key_code": "semicolon" }] + }, + { + "from": { "key_code": "r" }, + "to": [{ "key_code": "p" }] + }, + { + "from": { "key_code": "s" }, + "to": [{ "key_code": "r" }] + }, + { + "from": { "key_code": "semicolon" }, + "to": [{ "key_code": "o" }] + }, + { + "from": { "key_code": "t" }, + "to": [{ "key_code": "b" }] + }, + { + "from": { "key_code": "u" }, + "to": [{ "key_code": "l" }] + }, + { + "from": { "key_code": "v" }, + "to": [{ "key_code": "d" }] + }, + { + "from": { "key_code": "y" }, + "to": [{ "key_code": "j" }] + } + ] + }, + { + "identifiers": { + "is_keyboard": true, + "product_id": 591, + "vendor_id": 1452 + }, + "simple_modifications": [ + { + "from": { "key_code": "b" }, + "to": [{ "key_code": "v" }] + }, + { + "from": { "key_code": "caps_lock" }, + "to": [{ "key_code": "left_control" }] + }, + { + "from": { "key_code": "d" }, + "to": [{ "key_code": "s" }] + }, + { + "from": { "key_code": "e" }, + "to": [{ "key_code": "f" }] + }, + { + "from": { "key_code": "f" }, + "to": [{ "key_code": "t" }] + }, + { + "from": { "key_code": "h" }, + "to": [{ "key_code": "m" }] + }, + { + "from": { "key_code": "i" }, + "to": [{ "key_code": "u" }] + }, + { + "from": { "key_code": "j" }, + "to": [{ "key_code": "n" }] + }, + { + "from": { "key_code": "k" }, + "to": [{ "key_code": "e" }] + }, + { + "from": { "key_code": "l" }, + "to": [{ "key_code": "i" }] + }, + { + "from": { "key_code": "m" }, + "to": [{ "key_code": "h" }] + }, + { + "from": { "key_code": "n" }, + "to": [{ "key_code": "k" }] + }, + { + "from": { "key_code": "o" }, + "to": [{ "key_code": "y" }] + }, + { + "from": { "key_code": "p" }, + "to": [{ "key_code": "semicolon" }] + }, + { + "from": { "key_code": "r" }, + "to": [{ "key_code": "p" }] + }, + { + "from": { "key_code": "s" }, + "to": [{ "key_code": "r" }] + }, + { + "from": { "key_code": "semicolon" }, + "to": [{ "key_code": "o" }] + }, + { + "from": { "key_code": "t" }, + "to": [{ "key_code": "b" }] + }, + { + "from": { "key_code": "u" }, + "to": [{ "key_code": "l" }] + }, + { + "from": { "key_code": "v" }, + "to": [{ "key_code": "d" }] + }, + { + "from": { "key_code": "y" }, + "to": [{ "key_code": "j" }] + } + ] + }, + { + "identifiers": { + "is_keyboard": true, + "is_pointing_device": true, + "product_id": 591, + "vendor_id": 1452 + }, + "ignore": false, + "simple_modifications": [ + { + "from": { "key_code": "b" }, + "to": [{ "key_code": "v" }] + }, + { + "from": { "key_code": "caps_lock" }, + "to": [{ "key_code": "left_control" }] + }, + { + "from": { "key_code": "d" }, + "to": [{ "key_code": "s" }] + }, + { + "from": { "key_code": "e" }, + "to": [{ "key_code": "f" }] + }, + { + "from": { "key_code": "f" }, + "to": [{ "key_code": "t" }] + }, + { + "from": { "key_code": "h" }, + "to": [{ "key_code": "m" }] + }, + { + "from": { "key_code": "i" }, + "to": [{ "key_code": "u" }] + }, + { + "from": { "key_code": "j" }, + "to": [{ "key_code": "n" }] + }, + { + "from": { "key_code": "k" }, + "to": [{ "key_code": "e" }] + }, + { + "from": { "key_code": "l" }, + "to": [{ "key_code": "i" }] + }, + { + "from": { "key_code": "m" }, + "to": [{ "key_code": "h" }] + }, + { + "from": { "key_code": "n" }, + "to": [{ "key_code": "k" }] + }, + { + "from": { "key_code": "o" }, + "to": [{ "key_code": "y" }] + }, + { + "from": { "key_code": "p" }, + "to": [{ "key_code": "semicolon" }] + }, + { + "from": { "key_code": "r" }, + "to": [{ "key_code": "p" }] + }, + { + "from": { "key_code": "s" }, + "to": [{ "key_code": "r" }] + }, + { + "from": { "key_code": "semicolon" }, + "to": [{ "key_code": "o" }] + }, + { + "from": { "key_code": "t" }, + "to": [{ "key_code": "b" }] + }, + { + "from": { "key_code": "u" }, + "to": [{ "key_code": "l" }] + }, + { + "from": { "key_code": "v" }, + "to": [{ "key_code": "d" }] + }, + { + "from": { "key_code": "y" }, + "to": [{ "key_code": "j" }] + } + ] + } + ], + "name": "Default profile", + "selected": true, + "virtual_hid_keyboard": { "keyboard_type_v2": "ansi" } + } + ] +} diff --git a/home-modules/karabiner.nix b/home-modules/karabiner.nix new file mode 100644 index 0000000..c79e638 --- /dev/null +++ b/home-modules/karabiner.nix @@ -0,0 +1,5 @@ +{ ... }: { + home.file.".config/karabiner/karabiner.json" = { + source = ./explicit-configs/karabiner/karabiner.json; + }; +} diff --git a/hosts/macbook/configuration.nix b/hosts/macbook/configuration.nix index 14dfdd9..e31f012 100644 --- a/hosts/macbook/configuration.nix +++ b/hosts/macbook/configuration.nix @@ -29,6 +29,7 @@ "secretive" "gcc-arm-embedded" "librewolf" + "karabiner-elements" ]; }; diff --git a/hosts/macbook/home.nix b/hosts/macbook/home.nix index 1fc6a34..1318789 100644 --- a/hosts/macbook/home.nix +++ b/hosts/macbook/home.nix @@ -6,14 +6,14 @@ } : { imports = [ - ../../home-modules/tmux.nix - ../../home-modules/lazygit.nix - ../../home-modules/zsh.nix - ../../home-modules/starship.nix - ../../home-modules/nvim.nix ../../home-modules/direnv.nix - # I should update the module with an option for adding winodow decorations. ../../home-modules/ghostty-config.nix + ../../home-modules/karabiner.nix + ../../home-modules/lazygit.nix + ../../home-modules/nvim.nix + ../../home-modules/starship.nix + ../../home-modules/tmux.nix + ../../home-modules/zsh.nix ]; ghostty = {