refactor(hyprland): move terminal keybind into registry

This commit was merged in pull request #147.
This commit is contained in:
2026-10-10 15:41:32 -04:00
parent 85fadc5bfc
commit fddec14128
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"; options.modules.desktop.apps.ghostty.enable = lib.mkEnableOption "Ghostty as the desktop terminal";
config = lib.mkIf config.modules.desktop.apps.ghostty.enable { 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 ]; 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"; options.modules.desktop.session.hyprland.enable = lib.mkEnableOption "the Hyprland compositor";
config = lib.mkIf config.modules.desktop.session.hyprland.enable { config = lib.mkIf config.modules.desktop.session.hyprland.enable {
# This program integration owns the session, portals, and polkit, launched # This program integration owns the session, portals, and polkit, launched
# through the universal Wayland session manager. # through the universal Wayland session manager.
programs.hyprland = { programs.hyprland = {
@@ -34,14 +35,12 @@
settings = { settings = {
config.general.layout = "dwindle"; config.general.layout = "dwindle";
bind = [ bind = lib.mapAttrsToList (_name: keybind: {
{ _args = [
_args = [ keybind.keys
"SUPER + Return" (lib.generators.mkLuaInline "hl.dsp.exec_cmd(${lib.generators.toLua { } keybind.action.command})")
(lib.generators.mkLuaInline ''hl.dsp.exec_cmd("ghostty")'') ];
]; }) (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) ) (builtins.readDir dir)
); );
uniqueValue =
value: entries: builtins.length (lib.unique (map value entries)) == builtins.length entries;
in in
{ {
inherit collectNixFiles; inherit collectNixFiles;
removeNixSuffix = path: lib.removeSuffix ".nix" (builtins.baseNameOf path); removeNixSuffix = path: lib.removeSuffix ".nix" (builtins.baseNameOf path);
registry.predicates.uniqueValue = registry.predicates.uniqueValue = uniqueValue;
value: entries: builtins.length (lib.unique (map value entries)) == builtins.length entries;
registry.predicates.uniquePerHost =
value:
uniqueValue (entry: {
inherit (entry) host;
value = value entry;
});
bridgeName = id: "br-vlan${toString id}"; bridgeName = id: "br-vlan${toString id}";