refactor(hyprland): move terminal keybind into registry #147

Merged
alexion merged 1 commits from feat/hyprland-lua-navigation into main 2026-10-11 16:02:13 -04:00
4 changed files with 63 additions and 10 deletions

View File

@@ -12,6 +12,14 @@ in
options.modules.desktop.apps.ghostty.enable = lib.mkEnableOption "Ghostty as the desktop terminal";
config = lib.mkIf config.modules.desktop.apps.ghostty.enable {
registry.keybind.${config.networking.hostName}.ghostty = {
keys = "SUPER + Return";
action = {
kind = "exec";
command = "${pkgs.ghostty}/bin/ghostty";
};
};
home-manager.users.${user}.home.packages = [ pkgs.ghostty ];
};
}

View File

@@ -8,6 +8,7 @@
options.modules.desktop.session.hyprland.enable = lib.mkEnableOption "the Hyprland compositor";
config = lib.mkIf config.modules.desktop.session.hyprland.enable {
# This program integration owns the session, portals, and polkit, launched
# through the universal Wayland session manager.
programs.hyprland = {
@@ -34,14 +35,12 @@
settings = {
config.general.layout = "dwindle";
bind = [
{
bind = lib.mapAttrsToList (_name: keybind: {
_args = [
"SUPER + Return"
(lib.generators.mkLuaInline ''hl.dsp.exec_cmd("ghostty")'')
];
}
keybind.keys
(lib.generators.mkLuaInline "hl.dsp.exec_cmd(${lib.generators.toLua { } keybind.action.command})")
];
}) (lib.attrByPath [ config.networking.hostName ] { } config.registry.keybind);
};
};
};

View File

@@ -0,0 +1,37 @@
{ lib, util, ... }:
{
checks = [
{
assertion = util.registry.predicates.uniquePerHost (entry: entry.value.keys);
message = "Desktop keybinds must use unique key chords per host.";
}
];
type = lib.types.submodule {
options = {
keys = lib.mkOption {
description = "Sets the key chord for this desktop keybind.";
type = lib.types.str;
example = "SUPER + Return";
};
action = lib.mkOption {
description = "Declares the action this keybind runs.";
type = lib.types.submodule {
options = {
kind = lib.mkOption {
description = "Selects the keybind action kind.";
type = lib.types.enum [ "exec" ];
};
command = lib.mkOption {
description = "Command executed by this keybind.";
type = lib.types.str;
example = "ghostty";
};
};
};
};
};
};
}

View File

@@ -16,14 +16,23 @@ let
[ ]
) (builtins.readDir dir)
);
uniqueValue =
value: entries: builtins.length (lib.unique (map value entries)) == builtins.length entries;
in
{
inherit collectNixFiles;
removeNixSuffix = path: lib.removeSuffix ".nix" (builtins.baseNameOf path);
registry.predicates.uniqueValue =
value: entries: builtins.length (lib.unique (map value entries)) == builtins.length entries;
registry.predicates.uniqueValue = uniqueValue;
registry.predicates.uniquePerHost =
value:
uniqueValue (entry: {
inherit (entry) host;
value = value entry;
});
bridgeName = id: "br-vlan${toString id}";