Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions config/keyd/default.conf
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
-1234:5678

[main]
# Caps Lock = pure Super (for Hyprland hotkeys)
# SUPER: CapsLock/RightAlt → Hyprland "$mod" binds (window mgmt, app launch)
# These skip xremap and go directly to Hyprland.
capslock = layer(meta)

# Right Alt = pure Super (right-hand mirror of Caps Lock)
rightalt = layer(meta)

# Framework key = macOS-style Command (Hyper for all keys)
# Hyper: Framework key → Ctrl+Alt+Shift+Super (all four modifiers)
# xremap intercepts these and remaps to Ctrl for macOS-style app shortcuts.
# leftmeta is the actual keycode on Framework 13 AI 300
leftmeta = layer(cmd_hyper)
prog1 = layer(cmd_hyper)
Expand All @@ -28,7 +28,9 @@ rightshift = overload(shift, oneshot(rshift))
rightshift = capslock

[cmd_hyper:C-A-S-M]
# macOS-style Command → Hyper (Ctrl+Alt+Shift+Super)
# Every Framework+key emits Ctrl+Alt+Shift+Super+key (Hyper).
# xremap then converts Hyper+key → Ctrl+key for apps.
# Keys excluded from xremap (e.g. 3/4/5) pass through as Hyper to Hyprland.

[cmd_hyper+control]
# Framework+Ctrl+5 → terminal split in VS Code
Expand Down
1 change: 1 addition & 0 deletions home-manager/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ in
++ services
++ [
inputs.agenix.homeManagerModules.default
inputs.xremap.homeManagerModules.default
];

home.username = username;
Expand Down
1 change: 1 addition & 0 deletions home-manager/modules/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@
./npm-globals
./tailscale
./uv-globals
./xremap
./yek
]
122 changes: 122 additions & 0 deletions home-manager/modules/xremap/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
{
config,
lib,
pkgs,
inputs,
...
}:
let
inherit (inputs.host) isDesktop;
inherit (pkgs.stdenv) isLinux;

# Hyper = Framework key (keyd: [cmd_hyper:C-A-S-M]) → remapped to Ctrl for macOS-style shortcuts
hyperPrefix = "C-Alt-Shift-Super-";
ctrlPrefix = "C-";
# "f" is excluded — passes through as Hyper+F for Hyprland fullscreen bind.
# See: config/hyprland/hyprland.conf (Window Management section)
letters = [
"a"
"b"
"c"
"d"
"e"
"g"
"h"
"i"
"j"
"k"
"l"
"m"
"n"
"o"
"p"
"q"
"r"
"s"
"t"
"u"
"v"
"w"
"x"
"y"
"z"
];
Comment on lines +17 to +43

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The list of letters can be generated more concisely using lib.stringToCharacters. This improves readability and reduces the line count, making the code easier to maintain.

  letters = lib.stringToCharacters "abcdefghijklmnopqrstuvwxyz";

# Numbers 3, 4, 5 are intentionally excluded — they pass through as
# Hyper+3/4/5 for Hyprland screenshot/recording bindings.
# See: config/hyprland/hyprland.conf (screenshot section)
numbers = [
"0"
"1"
"2"
"6"
"7"
"8"
"9"
];
symbols = [
"semicolon"
"dot"
"comma"
"slash"
"grave"
"backslash"
"leftbrace"
"rightbrace"
"apostrophe"
];
navigation = [
"tab"
"backspace"
"left"
"right"
"up"
"down"
];
remapKeys = letters ++ numbers ++ symbols ++ navigation;
mkRemap =
keys:
builtins.listToAttrs (
map (key: {
name = "${hyperPrefix}${key}";
value = "${ctrlPrefix}${key}";
}) keys
);
# Framework+key → Ctrl+key for all apps (macOS-style shortcuts)
globalRemap = mkRemap remapKeys;
# Ghostty: Framework+C/V → Ctrl+Shift+C/V (terminal convention: Ctrl+C = SIGINT)
ghosttyRemap = globalRemap // {
"${hyperPrefix}c" = "C-Shift-c";
"${hyperPrefix}v" = "C-Shift-v";
};
in
{
config = lib.mkIf (isDesktop && isLinux) {
services.xremap = {
enable = true;
withWlroots = true;
watch = true;
# Only intercept keyd output — SUPER (CapsLock/RightAlt) goes straight to Hyprland
deviceNames = [ "keyd virtual keyboard" ];
config = {
keymap = [
{
name = "Framework Command (Ghostty)";
application.only = [ "com.mitchellh.ghostty" ];
remap = ghosttyRemap;
}
{
name = "Framework Command (Global)";
application.not = [ "com.mitchellh.ghostty" ];
remap = globalRemap;
}
];
};
};

# Upstream module already sets After/PartOf/Restart; only add extras.
systemd.user.services.xremap = {
Unit.StartLimitIntervalSec = 0;
Service.RestartSec = 3;
};
};
}
132 changes: 12 additions & 120 deletions named-hosts/matic/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,6 @@ inputs.nixpkgs.lib.nixosSystem {
# Kolide launcher
./kolide.nix

# Keyd configuration
../../config/keyd

# Xremap module
inputs.xremap.nixosModules.default

# Base system configuration
(
{ config, lib, ... }:
Expand Down Expand Up @@ -76,127 +70,25 @@ inputs.nixpkgs.lib.nixosSystem {

security.sudo.wheelNeedsPassword = false;

# Keyd configuration (Linux desktop only)
services.keyd.enable = true;

@cubic-dev-ai cubic-dev-ai Bot Feb 9, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: This configuration duplicates the existing config/keyd/default.nix module. Instead of inlining the configuration, restore the ../../config/keyd import to the modules list to maintain a Single Source of Truth and reduce clutter.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At named-hosts/matic/default.nix, line 74:

<comment>This configuration duplicates the existing `config/keyd/default.nix` module. Instead of inlining the configuration, restore the `../../config/keyd` import to the `modules` list to maintain a Single Source of Truth and reduce clutter.</comment>

<file context>
@@ -76,127 +70,25 @@ inputs.nixpkgs.lib.nixosSystem {
         security.sudo.wheelNeedsPassword = false;
 
+        # Keyd configuration (Linux desktop only)
+        services.keyd.enable = true;
+        users.groups.keyd = { };
+        systemd.services.keyd.serviceConfig = {
</file context>
Fix with Cubic

users.groups.keyd = { };
systemd.services.keyd.serviceConfig = {
CapabilityBoundingSet = [ "CAP_SETGID" ];
AmbientCapabilities = [ "CAP_SETGID" ];
};
systemd.services.keyd.restartTriggers = [
(builtins.hashFile "sha256" ../../config/keyd/default.conf)
];
environment.etc."keyd/default.conf".source = ../../config/keyd/default.conf;
Comment on lines +73 to +83

Copilot AI Feb 9, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The keyd configuration here duplicates the existing config/keyd/default.nix module (same enable/group/capabilities/restartTriggers/etc). Consider importing ../../config/keyd again (or reusing that module) instead of inlining, to reduce duplication and avoid future drift.

Copilot uses AI. Check for mistakes.

# Input remapping (xremap)
hardware.uinput.enable = true;
services.udev.extraRules = ''
KERNEL=="uinput", GROUP="input", TAG+="uaccess", MODE:="0660", OPTIONS+="static_node=uinput"
KERNEL=="event*", ATTRS{name}=="keyd virtual keyboard", GROUP="input", MODE:="0660"
KERNEL=="event*", ATTRS{name}=="keyd virtual pointer", GROUP="input", MODE:="0660"
'';
services.xremap =
let
hyperPrefix = "C-Alt-Shift-Super-";
ctrlPrefix = "C-";
letters = [
"a"
"b"
"c"
"d"
"e"
"f"
"g"
"h"
"i"
"j"
"k"
"l"
"m"
"n"
"o"
"p"
"q"
"r"
"s"
"t"
"u"
"v"
"w"
"x"
"y"
"z"
];
# Numbers 3, 4, 5 are intentionally excluded — they pass through as
# Hyper+3/4/5 for Hyprland screenshot/recording bindings.
# See: config/hyprland/hyprland.conf (screenshot section)
numbers = [
"0"
"1"
"2"
"6"
"7"
"8"
"9"
];
symbols = [
"semicolon"
"dot"
"comma"
"slash"
"grave"
"backslash"
"leftbrace"
"rightbrace"
"apostrophe"
];
navigation = [
"tab"
"backspace"
"left"
"right"
"up"
"down"
];
remapKeys = letters ++ numbers ++ symbols ++ navigation;
mkRemap =
keys:
builtins.listToAttrs (
map (key: {
name = "${hyperPrefix}${key}";
value = "${ctrlPrefix}${key}";
}) keys
);
globalRemap = mkRemap remapKeys;
# Override copy/paste to Ctrl+Shift (terminal convention: Ctrl+C = SIGINT).
# All other keys (including z for undo) inherit from globalRemap.
ghosttyRemap = globalRemap // {
"${hyperPrefix}c" = "C-Shift-c";
"${hyperPrefix}v" = "C-Shift-v";
};
in
{
enable = true;
serviceMode = "user";
userName = username;
withWlroots = true;
watch = true;
deviceNames = [ "keyd virtual keyboard" ];
config = {
keymap = [
{
name = "Framework Command (Ghostty)";
application.only = [ "com.mitchellh.ghostty" ];
remap = ghosttyRemap;
}
{
name = "Framework Command (Global)";
application.not = [ "com.mitchellh.ghostty" ];
remap = globalRemap;
}
];
};
};

# Ensure xremap starts after Hyprland and auto-restarts on failure
systemd.user.services.xremap = {
after = [ "graphical-session.target" ];
partOf = [ "graphical-session.target" ];
serviceConfig = {
Restart = "on-failure";
RestartSec = 3;
};
# StartLimitIntervalSec is a [Unit] directive, not [Service].
unitConfig.StartLimitIntervalSec = 0;
};

# AMD graphics with hardware acceleration
hardware.graphics.enable = true;
Expand Down
Loading