From 2f9955dfb82345eea30ffe9442c05ff90ec86ced Mon Sep 17 00:00:00 2001 From: alexion Date: Sat, 10 Oct 2026 14:19:34 -0400 Subject: [PATCH] refactor(hyprland): simplify keybind registry schema --- configs/nixos/registry/desktop-keybind.nix | 71 ++++++---------------- 1 file changed, 20 insertions(+), 51 deletions(-) diff --git a/configs/nixos/registry/desktop-keybind.nix b/configs/nixos/registry/desktop-keybind.nix index e148a73..f24379a 100644 --- a/configs/nixos/registry/desktop-keybind.nix +++ b/configs/nixos/registry/desktop-keybind.nix @@ -1,54 +1,4 @@ { lib, ... }: -let - actionType = lib.types.addCheck (lib.types.attrsOf lib.types.anything) isAction; - - isAction = - action: - builtins.hasAttr "type" action - && builtins.hasAttr action.type actionFields - && ( - let - fields = builtins.getAttr action.type actionFields; - allowedFields = [ "type" ] ++ fields; - in - lib.all (field: builtins.hasAttr field action) fields - && lib.all (field: lib.elem field allowedFields) (builtins.attrNames action) - && lib.all (field: actionFieldChecks.${field} action.${field}) fields - ); - - actionFields = { - exec = [ "command" ]; - focus = [ "direction" ]; - "move-window" = [ "direction" ]; - "resize-window" = [ - "x" - "y" - ]; - "toggle-floating" = [ ]; - fullscreen = [ ]; - layout = [ "message" ]; - "close-window" = [ ]; - "kill-window" = [ ]; - "focus-workspace" = [ "workspace" ]; - "move-to-workspace" = [ "workspace" ]; - }; - - actionFieldChecks = { - command = builtins.isString; - direction = - direction: - lib.elem direction [ - "left" - "down" - "up" - "right" - ]; - x = builtins.isInt; - y = builtins.isInt; - workspace = builtins.isInt; - message = builtins.isString; - }; -in { checks = [ { @@ -69,7 +19,26 @@ in }; action = lib.mkOption { - type = actionType; + type = lib.types.submodule { + freeformType = lib.types.attrsOf lib.types.anything; + + options.type = lib.mkOption { + type = lib.types.enum [ + "exec" + "focus" + "move-window" + "resize-window" + "toggle-floating" + "fullscreen" + "layout" + "close-window" + "kill-window" + "focus-workspace" + "move-to-workspace" + ]; + description = "Selects the desktop action this keybind triggers."; + }; + }; description = "Declares the desktop action for this keybind."; }; };