From 23aca282672bf7d18bb6720f77be8c16bb8b5496 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Wed, 24 Dec 2025 14:10:17 -0800 Subject: [PATCH] build(nix): add generated module opts and validation This commit adds NixOS module option generation for komorebi and komorebi-bar configurations, along with a nix and JSONSchema validation test harness that runs as part of `nix flake check`. `schemars-nixgen` (same as `schemars-docgen`, not sure if I'm gonna release this...) generates strongly-typed Nix option definitions from the generated JSONSchema files, allowing users to write type-checked Nix configurations that map directly to the config files. This will eventually be plugged into a nix-darwin module which I have yet to start writing. --- docs/komorebi.bar.example.json | 2 +- flake.nix | 2 + justfile | 6 + nix/komorebi-bar-options.nix | 1338 ++++++++++++++++++++++++++++ nix/komorebi-options.nix | 1231 +++++++++++++++++++++++++ nix/tests/default.nix | 74 ++ nix/tests/komorebi-bar-example.nix | 71 ++ nix/tests/komorebi-example.nix | 59 ++ 8 files changed, 2782 insertions(+), 1 deletion(-) create mode 100644 nix/komorebi-bar-options.nix create mode 100644 nix/komorebi-options.nix create mode 100644 nix/tests/default.nix create mode 100644 nix/tests/komorebi-bar-example.nix create mode 100644 nix/tests/komorebi-example.nix diff --git a/docs/komorebi.bar.example.json b/docs/komorebi.bar.example.json index 08625aad..9087a20a 100644 --- a/docs/komorebi.bar.example.json +++ b/docs/komorebi.bar.example.json @@ -18,7 +18,7 @@ "layout": { "enable": true }, - "focused_window": { + "focused_container": { "enable": true, "show_icon": true } diff --git a/flake.nix b/flake.nix index 880e21c8..4587c37b 100644 --- a/flake.nix +++ b/flake.nix @@ -165,6 +165,8 @@ }; komorebi-workspace-nextest = build.craneLib.cargoNextest build.individualCrateArgs; + + nix-options-validation = import ./nix/tests { inherit pkgs; }; }; packages = { diff --git a/justfile b/justfile index b4e1a2d3..95a29fd1 100644 --- a/justfile +++ b/justfile @@ -62,6 +62,12 @@ schemagen: cp schema.json komorebi-schema/komorebi.{{ version }}.schema.json cp schema.bar.json komorebi-schema/komorebi.bar.{{ version }}.schema.json +nixgen: + schemars-nixgen schema.json -o nix/komorebi-options.nix --name komorebi --description "komorebi for Mac configuration" + schemars-nixgen schema.bar.json -o nix/komorebi-bar-options.nix --name komorebi-bar --description "komorebi for Mac bar configuration" + nix fmt nix/ + nix build -f nix/tests/default.nix + schemapub: wrangler pages deploy --project-name komorebi-for-mac --branch main ./komorebi-schema diff --git a/nix/komorebi-bar-options.nix b/nix/komorebi-bar-options.nix new file mode 100644 index 00000000..1a18c75f --- /dev/null +++ b/nix/komorebi-bar-options.nix @@ -0,0 +1,1338 @@ +{ lib, ... }: +let + applicationsDisplayFormat = ( + lib.types.enum [ + "Icon" + "Text" + "IconAndText" + ] + ); + base16Value = ( + lib.types.enum [ + "Base00" + "Base01" + "Base02" + "Base03" + "Base04" + "Base05" + "Base06" + "Base07" + "Base08" + "Base09" + "Base0A" + "Base0B" + "Base0C" + "Base0D" + "Base0E" + "Base0F" + ] + ); + catppuccinValue = ( + lib.types.enum [ + "Rosewater" + "Flamingo" + "Pink" + "Mauve" + "Red" + "Maroon" + "Peach" + "Yellow" + "Green" + "Teal" + "Sky" + "Sapphire" + "Blue" + "Lavender" + "Text" + "Subtext1" + "Subtext0" + "Overlay2" + "Overlay1" + "Overlay0" + "Surface2" + "Surface1" + "Surface0" + "Base" + "Mantle" + "Crust" + ] + ); + colour = ( + lib.types.oneOf [ + (lib.types.submodule { + options = { + b = lib.mkOption { + type = lib.types.int; + description = "Blue"; + }; + g = lib.mkOption { + type = lib.types.int; + description = "Green"; + }; + r = lib.mkOption { + type = lib.types.int; + description = "Red"; + }; + }; + }) + lib.types.str + ] + ); + displayFormat = ( + lib.types.enum [ + "Icon" + "Text" + "TextAndIconOnSelected" + "IconAndText" + "IconAndTextOnSelected" + ] + ); + groupedSpacingOptions = ( + lib.types.oneOf [ + lib.types.number + (lib.types.listOf lib.types.number) + ] + ); + labelPrefix = ( + lib.types.enum [ + "None" + "Icon" + "Text" + "IconAndText" + ] + ); + position = ( + lib.types.submodule { + options = { + x = lib.mkOption { + type = lib.types.number; + description = "X coordinate"; + }; + y = lib.mkOption { + type = lib.types.number; + description = "Y coordinate"; + }; + }; + } + ); + spacingKind = ( + lib.types.oneOf [ + lib.types.number + (lib.types.submodule { + options = { + bottom = lib.mkOption { + type = lib.types.number; + }; + left = lib.mkOption { + type = lib.types.number; + }; + right = lib.mkOption { + type = lib.types.number; + }; + top = lib.mkOption { + type = lib.types.number; + }; + }; + }) + (lib.types.submodule { + options = { + horizontal = lib.mkOption { + type = (lib.types.nullOr groupedSpacingOptions); + default = null; + }; + vertical = lib.mkOption { + type = (lib.types.nullOr groupedSpacingOptions); + default = null; + }; + }; + }) + ] + ); + widgetConfig = ( + lib.types.submodule { + options = { + Applications = lib.mkOption { + type = ( + lib.types.nullOr ( + lib.types.submodule { + options = { + display = lib.mkOption { + type = (lib.types.nullOr applicationsDisplayFormat); + default = null; + description = "Default display format for all applications (optional).\nCould be overridden per application. Defaults to `Icon`."; + }; + enable = lib.mkOption { + type = lib.types.bool; + description = "Enables or disables the applications widget."; + }; + items = lib.mkOption { + type = ( + lib.types.listOf ( + lib.types.submodule { + options = { + command = lib.mkOption { + type = lib.types.str; + description = "Command to execute (e.g. path to the application or shell command)."; + }; + display = lib.mkOption { + type = (lib.types.nullOr applicationsDisplayFormat); + default = null; + description = "Display format for this application button (optional). Overrides global format if set."; + }; + enable = lib.mkOption { + type = (lib.types.nullOr lib.types.bool); + default = null; + description = "Whether to enable this application button (optional).\nInherits from the global `Applications` setting if omitted."; + }; + icon = lib.mkOption { + type = (lib.types.nullOr lib.types.str); + default = null; + description = "Optional icon: a path to an image or a text-based glyph (e.g., from Nerd Fonts).\nIf not set, and if the `command` is a path to an executable, an icon might be extracted from it.\nNote: glyphs require a compatible `font_family`."; + }; + name = lib.mkOption { + type = lib.types.str; + description = "Display name of the application."; + }; + show_command_on_hover = lib.mkOption { + type = (lib.types.nullOr lib.types.bool); + default = null; + description = "Whether to show the launch command on hover (optional).\nInherits from the global `Applications` setting if omitted."; + }; + }; + } + ) + ); + description = "List of configured applications to display."; + }; + show_command_on_hover = lib.mkOption { + type = (lib.types.nullOr lib.types.bool); + default = null; + description = "Whether to show the launch command on hover (optional).\nCould be overridden per application. Defaults to `false` if not set."; + }; + spacing = lib.mkOption { + type = (lib.types.nullOr lib.types.number); + default = null; + description = "Horizontal spacing between application buttons."; + }; + }; + } + ) + ); + default = null; + }; + Battery = lib.mkOption { + type = ( + lib.types.nullOr ( + lib.types.submodule { + options = { + auto_select_under = lib.mkOption { + type = (lib.types.nullOr lib.types.int); + default = null; + description = "Select when the current percentage is under this value [[1-100]]"; + }; + data_refresh_interval = lib.mkOption { + type = (lib.types.nullOr lib.types.int); + default = null; + description = "Data refresh interval (default: 10 seconds)"; + }; + enable = lib.mkOption { + type = lib.types.bool; + description = "Enable the Battery widget"; + }; + hide_on_full_charge = lib.mkOption { + type = (lib.types.nullOr lib.types.bool); + default = null; + description = "Hide the widget if the battery is at full charge"; + }; + label_prefix = lib.mkOption { + type = (lib.types.nullOr labelPrefix); + default = null; + description = "Display label prefix"; + }; + }; + } + ) + ); + default = null; + }; + Cpu = lib.mkOption { + type = ( + lib.types.nullOr ( + lib.types.submodule { + options = { + auto_select_over = lib.mkOption { + type = (lib.types.nullOr lib.types.int); + default = null; + description = "Select when the current percentage is over this value [[1-100]]"; + }; + data_refresh_interval = lib.mkOption { + type = (lib.types.nullOr lib.types.int); + default = null; + description = "Data refresh interval (default: 10 seconds)"; + }; + enable = lib.mkOption { + type = lib.types.bool; + description = "Enable the Cpu widget"; + }; + label_prefix = lib.mkOption { + type = (lib.types.nullOr labelPrefix); + default = null; + description = "Display label prefix"; + }; + }; + } + ) + ); + default = null; + }; + Date = lib.mkOption { + type = ( + lib.types.nullOr ( + lib.types.submodule { + options = { + enable = lib.mkOption { + type = lib.types.bool; + description = "Enable the Date widget"; + }; + format = lib.mkOption { + type = ( + lib.types.oneOf [ + (lib.types.enum [ + "MonthDateYear" + "YearMonthDate" + "DateMonthYear" + "DayDateMonthYear" + ]) + (lib.types.submodule { + options = { + Custom = lib.mkOption { + type = (lib.types.nullOr lib.types.str); + default = null; + }; + CustomModifiers = lib.mkOption { + type = ( + lib.types.nullOr ( + lib.types.submodule { + options = { + format = lib.mkOption { + type = lib.types.str; + description = "Custom format (https://docs.rs/chrono/latest/chrono/format/strftime/index.html)"; + }; + modifiers = lib.mkOption { + type = (lib.types.attrsOf lib.types.int); + description = "Additive modifiers for integer format specifiers (e.g. { \"%U\": 1 } to increment the zero-indexed week number by 1)"; + }; + }; + } + ) + ); + default = null; + }; + }; + }) + ] + ); + description = "Set the Date format"; + }; + label_prefix = lib.mkOption { + type = (lib.types.nullOr labelPrefix); + default = null; + description = "Display label prefix"; + }; + timezone = lib.mkOption { + type = (lib.types.nullOr lib.types.str); + default = null; + description = "TimeZone (https://docs.rs/chrono-tz/latest/chrono_tz/enum.Tz.html)\n\nUse a custom format to display additional information, i.e.:\n```json\n{\n \"Date\": {\n \"enable\": true,\n \"format\": { \"Custom\": \"%D %Z (Tokyo)\" },\n \"timezone\": \"Asia/Tokyo\"\n }\n}\n```"; + }; + }; + } + ) + ); + default = null; + }; + Komorebi = lib.mkOption { + type = ( + lib.types.nullOr ( + lib.types.submodule { + options = { + configuration_switcher = lib.mkOption { + type = ( + lib.types.nullOr ( + lib.types.submodule { + options = { + configurations = lib.mkOption { + type = (lib.types.attrsOf lib.types.str); + description = "A map of display friendly name => path to configuration.json"; + }; + enable = lib.mkOption { + type = lib.types.bool; + description = "Enable the Komorebi Configurations widget"; + }; + }; + } + ) + ); + default = null; + description = "Configure the Configuration Switcher widget"; + }; + focused_container = lib.mkOption { + type = ( + lib.types.nullOr ( + lib.types.submodule { + options = { + display = lib.mkOption { + type = (lib.types.nullOr displayFormat); + default = null; + description = "Display format of the currently focused container"; + }; + enable = lib.mkOption { + type = lib.types.bool; + description = "Enable the Komorebi Focused Container widget"; + }; + show_icon = lib.mkOption { + type = (lib.types.nullOr lib.types.bool); + default = null; + description = "DEPRECATED: use 'display' instead (Show the icon of the currently focused container)"; + }; + }; + } + ) + ); + default = null; + description = "Configure the Focused Container widget"; + }; + layout = lib.mkOption { + type = ( + lib.types.nullOr ( + lib.types.submodule { + options = { + display = lib.mkOption { + type = (lib.types.nullOr displayFormat); + default = null; + description = "Display format of the current layout"; + }; + enable = lib.mkOption { + type = lib.types.bool; + description = "Enable the Komorebi Layout widget"; + }; + options = lib.mkOption { + type = ( + lib.types.nullOr ( + lib.types.listOf ( + lib.types.nullOr ( + lib.types.enum [ + "BSP" + "Columns" + "Rows" + "VerticalStack" + "HorizontalStack" + "UltrawideVerticalStack" + "Grid" + "RightMainVerticalStack" + "Scrolling" + ] + ) + ) + ) + ); + default = null; + description = "List of layout options"; + }; + }; + } + ) + ); + default = null; + description = "Configure the Layout widget"; + }; + locked_container = lib.mkOption { + type = ( + lib.types.nullOr ( + lib.types.submodule { + options = { + display = lib.mkOption { + type = (lib.types.nullOr displayFormat); + default = null; + description = "Display format of the current locked state"; + }; + enable = lib.mkOption { + type = lib.types.bool; + description = "Enable the Komorebi Locked Container widget"; + }; + show_when_unlocked = lib.mkOption { + type = (lib.types.nullOr lib.types.bool); + default = null; + description = "Show the widget event if the layer is unlocked"; + }; + }; + } + ) + ); + default = null; + description = "Configure the Locked Container widget"; + }; + workspace_layer = lib.mkOption { + type = ( + lib.types.nullOr ( + lib.types.submodule { + options = { + display = lib.mkOption { + type = (lib.types.nullOr displayFormat); + default = null; + description = "Display format of the current layer"; + }; + enable = lib.mkOption { + type = lib.types.bool; + description = "Enable the Komorebi Workspace Layer widget"; + }; + show_when_tiling = lib.mkOption { + type = (lib.types.nullOr lib.types.bool); + default = null; + description = "Show the widget event if the layer is Tiling"; + }; + }; + } + ) + ); + default = null; + description = "Configure the Workspace Layer widget"; + }; + workspaces = lib.mkOption { + type = ( + lib.types.nullOr ( + lib.types.submodule { + options = { + display = lib.mkOption { + type = ( + lib.types.nullOr ( + lib.types.oneOf [ + lib.types.str + lib.types.str + lib.types.str + displayFormat + ] + ) + ); + default = null; + description = "Display format of the workspace"; + }; + enable = lib.mkOption { + type = lib.types.bool; + description = "Enable the Komorebi Workspaces widget"; + }; + hide_empty_workspaces = lib.mkOption { + type = lib.types.bool; + description = "Hide workspaces without any windows"; + }; + }; + } + ) + ); + default = null; + description = "Configure the Workspaces widget"; + }; + }; + } + ) + ); + default = null; + }; + Memory = lib.mkOption { + type = ( + lib.types.nullOr ( + lib.types.submodule { + options = { + auto_select_over = lib.mkOption { + type = (lib.types.nullOr lib.types.int); + default = null; + description = "Select when the current percentage is over this value [[1-100]]"; + }; + data_refresh_interval = lib.mkOption { + type = (lib.types.nullOr lib.types.int); + default = null; + description = "Data refresh interval (default: 10 seconds)"; + }; + enable = lib.mkOption { + type = lib.types.bool; + description = "Enable the Memory widget"; + }; + label_prefix = lib.mkOption { + type = (lib.types.nullOr labelPrefix); + default = null; + description = "Display label prefix"; + }; + }; + } + ) + ); + default = null; + }; + Network = lib.mkOption { + type = ( + lib.types.nullOr ( + lib.types.submodule { + options = { + activity_left_padding = lib.mkOption { + type = (lib.types.nullOr lib.types.int); + default = null; + description = "Characters to reserve for received and transmitted activity"; + }; + auto_select = lib.mkOption { + type = ( + lib.types.nullOr ( + lib.types.submodule { + options = { + received_over = lib.mkOption { + type = (lib.types.nullOr lib.types.int); + default = null; + description = "Select the received data when it's over this value"; + }; + total_received_over = lib.mkOption { + type = (lib.types.nullOr lib.types.int); + default = null; + description = "Select the total received data when it's over this value"; + }; + total_transmitted_over = lib.mkOption { + type = (lib.types.nullOr lib.types.int); + default = null; + description = "Select the total transmitted data when it's over this value"; + }; + transmitted_over = lib.mkOption { + type = (lib.types.nullOr lib.types.int); + default = null; + description = "Select the transmitted data when it's over this value"; + }; + }; + } + ) + ); + default = null; + description = "Select when the value is over a limit (1MiB is 1048576 bytes (1024*1024))"; + }; + data_refresh_interval = lib.mkOption { + type = (lib.types.nullOr lib.types.int); + default = null; + description = "Data refresh interval (default: 10 seconds)"; + }; + enable = lib.mkOption { + type = lib.types.bool; + description = "Enable the Network widget"; + }; + label_prefix = lib.mkOption { + type = (lib.types.nullOr labelPrefix); + default = null; + description = "Display label prefix"; + }; + show_activity = lib.mkOption { + type = lib.types.bool; + description = "Show received and transmitted activity"; + }; + show_default_interface = lib.mkOption { + type = (lib.types.nullOr lib.types.bool); + default = null; + description = "Show default interface"; + }; + show_total_activity = lib.mkOption { + type = lib.types.bool; + description = "Show total received and transmitted activity"; + }; + }; + } + ) + ); + default = null; + }; + Storage = lib.mkOption { + type = ( + lib.types.nullOr ( + lib.types.submodule { + options = { + auto_hide_under = lib.mkOption { + type = (lib.types.nullOr lib.types.int); + default = null; + description = "Hide when the current percentage is under this value [[1-100]]"; + }; + auto_select_over = lib.mkOption { + type = (lib.types.nullOr lib.types.int); + default = null; + description = "Select when the current percentage is over this value [[1-100]]"; + }; + data_refresh_interval = lib.mkOption { + type = (lib.types.nullOr lib.types.int); + default = null; + description = "Data refresh interval (default: 10 seconds)"; + }; + enable = lib.mkOption { + type = lib.types.bool; + description = "Enable the Storage widget"; + }; + label_prefix = lib.mkOption { + type = (lib.types.nullOr labelPrefix); + default = null; + description = "Display label prefix"; + }; + show_read_only_disks = lib.mkOption { + type = (lib.types.nullOr lib.types.bool); + default = null; + description = "Show disks that are read only. (default: false)"; + }; + show_removable_disks = lib.mkOption { + type = (lib.types.nullOr lib.types.bool); + default = null; + description = "Show removable disks. (default: true)"; + }; + }; + } + ) + ); + default = null; + }; + Time = lib.mkOption { + type = ( + lib.types.nullOr ( + lib.types.submodule { + options = { + changing_icon = lib.mkOption { + type = (lib.types.nullOr lib.types.bool); + default = null; + description = "Change the icon depending on the time. The default icon is used between 8:30 and 12:00. (default: false)"; + }; + enable = lib.mkOption { + type = lib.types.bool; + description = "Enable the Time widget"; + }; + format = lib.mkOption { + type = ( + lib.types.oneOf [ + (lib.types.enum [ + "TwelveHour" + "TwelveHourWithoutSeconds" + "TwentyFourHour" + "TwentyFourHourWithoutSeconds" + "BinaryCircle" + "BinaryRectangle" + ]) + (lib.types.submodule { + options = { + Custom = lib.mkOption { + type = (lib.types.nullOr lib.types.str); + default = null; + }; + }; + }) + ] + ); + description = "Set the Time format"; + }; + label_prefix = lib.mkOption { + type = (lib.types.nullOr labelPrefix); + default = null; + description = "Display label prefix"; + }; + timezone = lib.mkOption { + type = (lib.types.nullOr lib.types.str); + default = null; + description = "TimeZone (https://docs.rs/chrono-tz/latest/chrono_tz/enum.Tz.html)\n\nUse a custom format to display additional information, i.e.:\n```json\n{\n \"Time\": {\n \"enable\": true,\n \"format\": { \"Custom\": \"%T %Z (Tokyo)\" },\n \"timezone\": \"Asia/Tokyo\"\n }\n}\n```"; + }; + }; + } + ) + ); + default = null; + }; + Update = lib.mkOption { + type = ( + lib.types.nullOr ( + lib.types.submodule { + options = { + data_refresh_interval = lib.mkOption { + type = (lib.types.nullOr lib.types.int); + default = null; + description = "Data refresh interval (default: 12 hours)"; + }; + enable = lib.mkOption { + type = lib.types.bool; + description = "Enable the Update widget"; + }; + label_prefix = lib.mkOption { + type = (lib.types.nullOr labelPrefix); + default = null; + description = "Display label prefix"; + }; + }; + } + ) + ); + default = null; + }; + }; + } + ); +in +{ + options.komorebi-bar = lib.mkOption { + type = lib.types.submodule { + options = { + center_widgets = lib.mkOption { + type = (lib.types.nullOr (lib.types.listOf widgetConfig)); + default = null; + description = "Center widgets (ordered left-to-right)"; + }; + font_family = lib.mkOption { + type = (lib.types.nullOr lib.types.str); + default = null; + description = "Font family"; + }; + font_size = lib.mkOption { + type = (lib.types.nullOr lib.types.number); + default = null; + description = "Font size (default: 12.5)"; + }; + frame = lib.mkOption { + type = ( + lib.types.nullOr ( + lib.types.submodule { + options = { + inner_margin = lib.mkOption { + type = position; + description = "Margin inside the painted frame"; + }; + }; + } + ) + ); + default = null; + description = "Frame options (see: https://docs.rs/egui/latest/egui/containers/frame/struct.Frame.html)"; + }; + grouping = lib.mkOption { + type = ( + lib.types.nullOr ( + lib.types.submodule { + options = { + kind = lib.mkOption { + type = ( + lib.types.enum [ + "None" + "Bar" + "Alignment" + "Widget" + ] + ); + }; + }; + } + ) + ); + default = null; + description = "Visual grouping for widgets"; + }; + height = lib.mkOption { + type = (lib.types.nullOr lib.types.number); + default = null; + description = "Bar height (default: 50)"; + }; + icon_scale = lib.mkOption { + type = (lib.types.nullOr lib.types.number); + default = null; + description = "Scale of the icons relative to the font_size [[1.0-2.0]]. (default: 1.4)"; + }; + left_widgets = lib.mkOption { + type = (lib.types.listOf widgetConfig); + description = "Options for mouse interaction on the bar\nLeft side widgets (ordered left-to-right)"; + }; + margin = lib.mkOption { + type = (lib.types.nullOr spacingKind); + default = null; + description = "Bar margin. Use one value for all sides or use a grouped margin for horizontal and/or\nvertical definition which can each take a single value for a symmetric margin or two\nvalues for each side, i.e.:\n```json\n\"margin\": {\n \"horizontal\": 10\n}\n```\nor:\n```json\n\"margin\": {\n \"vertical\": [top, bottom]\n}\n```\nYou can also set individual margin on each side like this:\n```json\n\"margin\": {\n \"top\": 10,\n \"bottom\": 10,\n \"left\": 10,\n \"right\": 10,\n}\n```\nBy default, margin is set to 0 on all sides."; + }; + max_label_width = lib.mkOption { + type = (lib.types.nullOr lib.types.number); + default = null; + description = "Max label width before text truncation (default: 400.0)"; + }; + monitor = lib.mkOption { + type = ( + lib.types.oneOf [ + lib.types.int + (lib.types.submodule { + options = { + index = lib.mkOption { + type = lib.types.int; + description = "Komorebi monitor index of the monitor on which to render the bar"; + }; + work_area_offset = lib.mkOption { + type = ( + lib.types.nullOr ( + lib.types.submodule { + options = { + bottom = lib.mkOption { + type = lib.types.int; + }; + left = lib.mkOption { + type = lib.types.int; + }; + right = lib.mkOption { + type = lib.types.int; + }; + top = lib.mkOption { + type = lib.types.int; + }; + }; + } + ) + ); + default = null; + description = "Automatically apply a work area offset for this monitor to accommodate the bar"; + }; + }; + }) + ] + ); + description = "The monitor index or the full monitor options"; + }; + padding = lib.mkOption { + type = (lib.types.nullOr spacingKind); + default = null; + description = "Bar padding. Use one value for all sides or use a grouped padding for horizontal and/or\nvertical definition which can each take a single value for a symmetric padding or two\nvalues for each side, i.e.:\n```json\n\"padding\": {\n \"horizontal\": 10\n}\n```\nor:\n```json\n\"padding\": {\n \"horizontal\": [left, right]\n}\n```\nYou can also set individual padding on each side like this:\n```json\n\"padding\": {\n \"top\": 10,\n \"bottom\": 10,\n \"left\": 10,\n \"right\": 10,\n}\n```\nBy default, padding is set to 10 on all sides."; + }; + position = lib.mkOption { + type = ( + lib.types.nullOr ( + lib.types.submodule { + options = { + end = lib.mkOption { + type = (lib.types.nullOr position); + default = null; + description = "The desired size of the bar from the starting position (usually monitor width x desired height)"; + }; + start = lib.mkOption { + type = (lib.types.nullOr position); + default = null; + description = "The desired starting position of the bar (0,0 = top left of the screen)"; + }; + }; + } + ) + ); + default = null; + description = "Bar positioning options"; + }; + right_widgets = lib.mkOption { + type = (lib.types.listOf widgetConfig); + description = "Right side widgets (ordered left-to-right)"; + }; + theme = lib.mkOption { + type = ( + lib.types.nullOr ( + lib.types.submodule { + options = { + palette = lib.mkOption { + type = ( + lib.types.enum [ + "Catppuccin" + "Base16" + "Custom" + ] + ); + }; + colours = lib.mkOption { + type = ( + lib.types.nullOr ( + lib.types.submodule { + options = { + base_00 = lib.mkOption { + type = colour; + }; + base_01 = lib.mkOption { + type = colour; + }; + base_02 = lib.mkOption { + type = colour; + }; + base_03 = lib.mkOption { + type = colour; + }; + base_04 = lib.mkOption { + type = colour; + }; + base_05 = lib.mkOption { + type = colour; + }; + base_06 = lib.mkOption { + type = colour; + }; + base_07 = lib.mkOption { + type = colour; + }; + base_08 = lib.mkOption { + type = colour; + }; + base_09 = lib.mkOption { + type = colour; + }; + base_0a = lib.mkOption { + type = colour; + }; + base_0b = lib.mkOption { + type = colour; + }; + base_0c = lib.mkOption { + type = colour; + }; + base_0d = lib.mkOption { + type = colour; + }; + base_0e = lib.mkOption { + type = colour; + }; + base_0f = lib.mkOption { + type = colour; + }; + }; + } + ) + ); + default = null; + }; + auto_select_text = lib.mkOption { + type = ( + lib.types.nullOr ( + lib.types.oneOf [ + (lib.types.nullOr catppuccinValue) + (lib.types.nullOr base16Value) + ] + ) + ); + default = null; + }; + accent = lib.mkOption { + type = ( + lib.types.nullOr ( + lib.types.oneOf [ + (lib.types.nullOr catppuccinValue) + (lib.types.nullOr base16Value) + ] + ) + ); + default = null; + }; + auto_select_fill = lib.mkOption { + type = ( + lib.types.nullOr ( + lib.types.oneOf [ + (lib.types.nullOr catppuccinValue) + (lib.types.nullOr base16Value) + ] + ) + ); + default = null; + }; + name = lib.mkOption { + type = ( + lib.types.nullOr ( + lib.types.oneOf [ + (lib.types.enum [ + "Frappe" + "Latte" + "Macchiato" + "Mocha" + ]) + (lib.types.enum [ + "3024" + "Apathy" + "Apprentice" + "Ashes" + "AtelierCaveLight" + "AtelierCave" + "AtelierDuneLight" + "AtelierDune" + "AtelierEstuaryLight" + "AtelierEstuary" + "AtelierForestLight" + "AtelierForest" + "AtelierHeathLight" + "AtelierHeath" + "AtelierLakesideLight" + "AtelierLakeside" + "AtelierPlateauLight" + "AtelierPlateau" + "AtelierSavannaLight" + "AtelierSavanna" + "AtelierSeasideLight" + "AtelierSeaside" + "AtelierSulphurpoolLight" + "AtelierSulphurpool" + "Atlas" + "AyuDark" + "AyuLight" + "AyuMirage" + "Aztec" + "Bespin" + "BlackMetalBathory" + "BlackMetalBurzum" + "BlackMetalDarkFuneral" + "BlackMetalGorgoroth" + "BlackMetalImmortal" + "BlackMetalKhold" + "BlackMetalMarduk" + "BlackMetalMayhem" + "BlackMetalNile" + "BlackMetalVenom" + "BlackMetal" + "Blueforest" + "Blueish" + "Brewer" + "Bright" + "Brogrammer" + "BrushtreesDark" + "Brushtrees" + "Caroline" + "CatppuccinFrappe" + "CatppuccinLatte" + "CatppuccinMacchiato" + "CatppuccinMocha" + "Chalk" + "Circus" + "ClassicDark" + "ClassicLight" + "Codeschool" + "Colors" + "Cupcake" + "Cupertino" + "DaOneBlack" + "DaOneGray" + "DaOneOcean" + "DaOnePaper" + "DaOneSea" + "DaOneWhite" + "DanqingLight" + "Danqing" + "Darcula" + "Darkmoss" + "Darktooth" + "Darkviolet" + "Decaf" + "DefaultDark" + "DefaultLight" + "Dirtysea" + "Dracula" + "EdgeDark" + "EdgeLight" + "Eighties" + "EmbersLight" + "Embers" + "Emil" + "EquilibriumDark" + "EquilibriumGrayDark" + "EquilibriumGrayLight" + "EquilibriumLight" + "Eris" + "Espresso" + "EvaDim" + "Eva" + "EvenokDark" + "EverforestDarkHard" + "Everforest" + "Flat" + "Framer" + "FruitSoda" + "Gigavolt" + "Github" + "GoogleDark" + "GoogleLight" + "Gotham" + "GrayscaleDark" + "GrayscaleLight" + "Greenscreen" + "Gruber" + "GruvboxDarkHard" + "GruvboxDarkMedium" + "GruvboxDarkPale" + "GruvboxDarkSoft" + "GruvboxLightHard" + "GruvboxLightMedium" + "GruvboxLightSoft" + "GruvboxMaterialDarkHard" + "GruvboxMaterialDarkMedium" + "GruvboxMaterialDarkSoft" + "GruvboxMaterialLightHard" + "GruvboxMaterialLightMedium" + "GruvboxMaterialLightSoft" + "Hardcore" + "Harmonic16Dark" + "Harmonic16Light" + "HeetchLight" + "Heetch" + "Helios" + "Hopscotch" + "HorizonDark" + "HorizonLight" + "HorizonTerminalDark" + "HorizonTerminalLight" + "HumanoidDark" + "HumanoidLight" + "IaDark" + "IaLight" + "Icy" + "Irblack" + "Isotope" + "Jabuti" + "Kanagawa" + "Katy" + "Kimber" + "Lime" + "Macintosh" + "Marrakesh" + "Materia" + "MaterialDarker" + "MaterialLighter" + "MaterialPalenight" + "MaterialVivid" + "Material" + "MeasuredDark" + "MeasuredLight" + "MellowPurple" + "MexicoLight" + "Mocha" + "Monokai" + "Moonlight" + "Mountain" + "Nebula" + "NordLight" + "Nord" + "Nova" + "Ocean" + "Oceanicnext" + "OneLight" + "OnedarkDark" + "Onedark" + "OutrunDark" + "OxocarbonDark" + "OxocarbonLight" + "Pandora" + "PapercolorDark" + "PapercolorLight" + "Paraiso" + "Pasque" + "Phd" + "Pico" + "Pinky" + "Pop" + "Porple" + "PreciousDarkEleven" + "PreciousDarkFifteen" + "PreciousLightWarm" + "PreciousLightWhite" + "PrimerDarkDimmed" + "PrimerDark" + "PrimerLight" + "Purpledream" + "Qualia" + "Railscasts" + "Rebecca" + "RosePineDawn" + "RosePineMoon" + "RosePine" + "Saga" + "Sagelight" + "Sakura" + "Sandcastle" + "SelenizedBlack" + "SelenizedDark" + "SelenizedLight" + "SelenizedWhite" + "Seti" + "ShadesOfPurple" + "ShadesmearDark" + "ShadesmearLight" + "Shapeshifter" + "SilkDark" + "SilkLight" + "Snazzy" + "SolarflareLight" + "Solarflare" + "SolarizedDark" + "SolarizedLight" + "Spaceduck" + "Spacemacs" + "Sparky" + "StandardizedDark" + "StandardizedLight" + "Stella" + "StillAlive" + "Summercamp" + "SummerfruitDark" + "SummerfruitLight" + "SynthMidnightDark" + "SynthMidnightLight" + "Tango" + "Tarot" + "Tender" + "TerracottaDark" + "Terracotta" + "TokyoCityDark" + "TokyoCityLight" + "TokyoCityTerminalDark" + "TokyoCityTerminalLight" + "TokyoNightDark" + "TokyoNightLight" + "TokyoNightMoon" + "TokyoNightStorm" + "TokyoNightTerminalDark" + "TokyoNightTerminalLight" + "TokyoNightTerminalStorm" + "TokyodarkTerminal" + "Tokyodark" + "TomorrowNightEighties" + "TomorrowNight" + "Tomorrow" + "Tube" + "Twilight" + "UnikittyDark" + "UnikittyLight" + "UnikittyReversible" + "Uwunicorn" + "Vesper" + "Vice" + "Vulcan" + "Windows10Light" + "Windows10" + "Windows95Light" + "Windows95" + "WindowsHighcontrastLight" + "WindowsHighcontrast" + "WindowsNtLight" + "WindowsNt" + "Woodland" + "XcodeDusk" + "Zenbones" + "Zenburn" + ]) + ] + ) + ); + default = null; + }; + }; + } + ) + ); + default = null; + description = "Theme"; + }; + transparency_alpha = lib.mkOption { + type = (lib.types.nullOr lib.types.int); + default = null; + description = "Alpha value for the color transparency [[0-255]] (default: 200)"; + }; + widget_spacing = lib.mkOption { + type = (lib.types.nullOr lib.types.number); + default = null; + description = "Spacing between widgets (default: 10.0)"; + }; + }; + }; + default = { }; + description = "komorebi for Mac bar configuration"; + }; +} diff --git a/nix/komorebi-options.nix b/nix/komorebi-options.nix new file mode 100644 index 00000000..79f4f1ed --- /dev/null +++ b/nix/komorebi-options.nix @@ -0,0 +1,1231 @@ +{ lib, ... }: +let + animationStyle = ( + lib.types.oneOf [ + (lib.types.enum [ + "Linear" + "EaseInSine" + "EaseOutSine" + "EaseInOutSine" + "EaseInQuad" + "EaseOutQuad" + "EaseInOutQuad" + "EaseInCubic" + "EaseOutCubic" + "EaseInOutCubic" + "EaseInQuart" + "EaseOutQuart" + "EaseInOutQuart" + "EaseInQuint" + "EaseOutQuint" + "EaseInOutQuint" + "EaseInExpo" + "EaseOutExpo" + "EaseInOutExpo" + "EaseInCirc" + "EaseOutCirc" + "EaseInOutCirc" + "EaseInBack" + "EaseOutBack" + "EaseInOutBack" + "EaseInElastic" + "EaseOutElastic" + "EaseInOutElastic" + "EaseInBounce" + "EaseOutBounce" + "EaseInOutBounce" + ]) + (lib.types.submodule { + options = { + CubicBezier = lib.mkOption { + type = (lib.types.nullOr (lib.types.listOf lib.types.number)); + default = null; + }; + }; + }) + ] + ); + base16Value = ( + lib.types.enum [ + "Base00" + "Base01" + "Base02" + "Base03" + "Base04" + "Base05" + "Base06" + "Base07" + "Base08" + "Base09" + "Base0A" + "Base0B" + "Base0C" + "Base0D" + "Base0E" + "Base0F" + ] + ); + catppuccinValue = ( + lib.types.enum [ + "Rosewater" + "Flamingo" + "Pink" + "Mauve" + "Red" + "Maroon" + "Peach" + "Yellow" + "Green" + "Teal" + "Sky" + "Sapphire" + "Blue" + "Lavender" + "Text" + "Subtext1" + "Subtext0" + "Overlay2" + "Overlay1" + "Overlay0" + "Surface2" + "Surface1" + "Surface0" + "Base" + "Mantle" + "Crust" + ] + ); + colour = ( + lib.types.oneOf [ + (lib.types.submodule { + options = { + b = lib.mkOption { + type = lib.types.int; + description = "Blue"; + }; + g = lib.mkOption { + type = lib.types.int; + description = "Green"; + }; + r = lib.mkOption { + type = lib.types.int; + description = "Red"; + }; + }; + }) + lib.types.str + ] + ); + defaultLayout = ( + lib.types.enum [ + "BSP" + "Columns" + "Rows" + "VerticalStack" + "HorizontalStack" + "UltrawideVerticalStack" + "Grid" + "RightMainVerticalStack" + "Scrolling" + ] + ); + floatingLayerBehaviour = ( + lib.types.enum [ + "Tile" + "Float" + ] + ); + idWithIdentifier = ( + lib.types.submodule { + options = { + id = lib.mkOption { + type = lib.types.str; + }; + kind = lib.mkOption { + type = ( + lib.types.enum [ + "Exe" + "Class" + "Title" + "Path" + ] + ); + }; + matching_strategy = lib.mkOption { + type = ( + lib.types.nullOr ( + lib.types.enum [ + "Legacy" + "Equals" + "StartsWith" + "EndsWith" + "Contains" + "Regex" + "DoesNotEndWith" + "DoesNotStartWith" + "DoesNotEqual" + "DoesNotContain" + ] + ) + ); + default = null; + }; + }; + } + ); + matchingRule = ( + lib.types.oneOf [ + idWithIdentifier + (lib.types.listOf idWithIdentifier) + ] + ); + pathBuf = lib.types.str; + placement = ( + lib.types.enum [ + "None" + "Center" + "CenterAndResize" + ] + ); + rect = ( + lib.types.submodule { + options = { + bottom = lib.mkOption { + type = lib.types.int; + }; + left = lib.mkOption { + type = lib.types.int; + }; + right = lib.mkOption { + type = lib.types.int; + }; + top = lib.mkOption { + type = lib.types.int; + }; + }; + } + ); + wallpaper = ( + lib.types.submodule { + options = { + generate_theme = lib.mkOption { + type = (lib.types.nullOr lib.types.bool); + default = null; + description = "Generate and apply Base16 theme for this wallpaper (default: true)"; + }; + path = lib.mkOption { + type = pathBuf; + description = "Path to the wallpaper image file"; + }; + theme_options = lib.mkOption { + type = ( + lib.types.nullOr ( + lib.types.submodule { + options = { + bar_accent = lib.mkOption { + type = (lib.types.nullOr base16Value); + default = null; + description = "Komorebi status bar accent (default: Base0D)"; + }; + floating_border = lib.mkOption { + type = (lib.types.nullOr base16Value); + default = null; + description = "Border colour when the window is floating (default: Base09)"; + }; + monocle_border = lib.mkOption { + type = (lib.types.nullOr base16Value); + default = null; + description = "Border colour when the container is in monocle mode (default: Base0F)"; + }; + single_border = lib.mkOption { + type = (lib.types.nullOr base16Value); + default = null; + description = "Border colour when the container contains a single window (default: Base0D)"; + }; + stack_border = lib.mkOption { + type = (lib.types.nullOr base16Value); + default = null; + description = "Border colour when the container contains multiple windows (default: Base0B)"; + }; + theme_variant = lib.mkOption { + type = ( + lib.types.nullOr ( + lib.types.enum [ + "Dark" + "Light" + ] + ) + ); + default = null; + description = "Specify Light or Dark variant for theme generation (default: Dark)"; + }; + unfocused_border = lib.mkOption { + type = (lib.types.nullOr base16Value); + default = null; + description = "Border colour when the container is unfocused (default: Base01)"; + }; + unfocused_locked_border = lib.mkOption { + type = (lib.types.nullOr base16Value); + default = null; + description = "Border colour when the container is unfocused and locked (default: Base08)"; + }; + }; + } + ) + ); + default = null; + description = "Specify Light or Dark variant for theme generation (default: Dark)"; + }; + }; + } + ); + windowContainerBehaviour = ( + lib.types.enum [ + "Create" + "Append" + ] + ); +in +{ + options.komorebi = lib.mkOption { + type = lib.types.submodule { + options = { + animation = lib.mkOption { + type = ( + lib.types.nullOr ( + lib.types.submodule { + options = { + duration = lib.mkOption { + type = ( + lib.types.nullOr ( + lib.types.oneOf [ + (lib.types.attrsOf lib.types.int) + lib.types.int + ] + ) + ); + default = null; + description = "Set the animation duration in ms (default: 250)"; + }; + enabled = lib.mkOption { + type = ( + lib.types.oneOf [ + (lib.types.attrsOf lib.types.bool) + lib.types.bool + ] + ); + description = "Enable or disable animations (default: false)"; + }; + fps = lib.mkOption { + type = (lib.types.nullOr lib.types.int); + default = null; + description = "Set the animation FPS (default: 60)"; + }; + style = lib.mkOption { + type = ( + lib.types.nullOr ( + lib.types.oneOf [ + (lib.types.attrsOf animationStyle) + animationStyle + ] + ) + ); + default = null; + description = "Set the animation style (default: Linear)"; + }; + }; + } + ) + ); + default = null; + description = "Animations configuration options"; + }; + app_specific_configuration_path = lib.mkOption { + type = ( + lib.types.nullOr ( + lib.types.oneOf [ + pathBuf + (lib.types.listOf pathBuf) + ] + ) + ); + default = null; + description = "Path to applications.json from komorebi-application-specific-configurations (default: None)"; + }; + border = lib.mkOption { + type = (lib.types.nullOr lib.types.bool); + default = null; + description = "Display window borders (default: true)"; + }; + border_colours = lib.mkOption { + type = ( + lib.types.nullOr ( + lib.types.submodule { + options = { + floating = lib.mkOption { + type = (lib.types.nullOr colour); + default = null; + description = "Border colour when the container is in floating mode"; + }; + monocle = lib.mkOption { + type = (lib.types.nullOr colour); + default = null; + description = "Border colour when the container is in monocle mode"; + }; + single = lib.mkOption { + type = (lib.types.nullOr colour); + default = null; + description = "Border colour when the container contains a single window"; + }; + stack = lib.mkOption { + type = (lib.types.nullOr colour); + default = null; + description = "Border colour when the container contains multiple windows"; + }; + unfocused = lib.mkOption { + type = (lib.types.nullOr colour); + default = null; + description = "Border colour when the container is unfocused"; + }; + unfocused_locked = lib.mkOption { + type = (lib.types.nullOr colour); + default = null; + description = "Border colour when the container is unfocused and locked"; + }; + }; + } + ) + ); + default = null; + description = "Window border colours for different container types (has no effect if a theme is defined)"; + }; + border_offset = lib.mkOption { + type = (lib.types.nullOr lib.types.int); + default = null; + description = "Offset of window borders (default: 5)"; + }; + border_overflow_applications = lib.mkOption { + type = (lib.types.nullOr (lib.types.listOf matchingRule)); + default = null; + description = "Identify border overflow applications"; + }; + border_radius = lib.mkOption { + type = (lib.types.nullOr lib.types.int); + default = null; + description = "Radius of window borders (default: 10)"; + }; + border_width = lib.mkOption { + type = (lib.types.nullOr lib.types.int); + default = null; + description = "Width of window borders (default: 6)"; + }; + cross_boundary_behaviour = lib.mkOption { + type = ( + lib.types.nullOr ( + lib.types.enum [ + "Workspace" + "Monitor" + ] + ) + ); + default = null; + description = "Determine what happens when an action is called on a window at a monitor boundary (default: Monitor)"; + }; + cross_monitor_move_behaviour = lib.mkOption { + type = ( + lib.types.nullOr ( + lib.types.enum [ + "Swap" + "Insert" + "NoOp" + ] + ) + ); + default = null; + description = "Determine what happens when a window is moved across a monitor boundary (default: Swap)"; + }; + default_container_padding = lib.mkOption { + type = (lib.types.nullOr lib.types.int); + default = null; + description = "Global default container padding (default: 10)"; + }; + default_workspace_padding = lib.mkOption { + type = (lib.types.nullOr lib.types.int); + default = null; + description = "Add transparency to unfocused windows (default: false)\nGlobal default workspace padding (default: 10)"; + }; + display_index_preferences = lib.mkOption { + type = (lib.types.nullOr (lib.types.attrsOf lib.types.str)); + default = null; + description = "Set display index preferences"; + }; + float_override = lib.mkOption { + type = (lib.types.nullOr lib.types.bool); + default = null; + description = "Enable or disable float override, which makes it so every new window opens in floating mode\n(default: false)"; + }; + float_override_placement = lib.mkOption { + type = (lib.types.nullOr placement); + default = null; + description = "Determines the `Placement` to be used when spawning a window with float override active\n(default: None)"; + }; + float_rule_placement = lib.mkOption { + type = (lib.types.nullOr placement); + default = null; + description = "Determines the `Placement` to be used when spawning a window that matches a\n'floating_applications' rule (default: None)"; + }; + floating_applications = lib.mkOption { + type = (lib.types.nullOr (lib.types.listOf matchingRule)); + default = null; + description = "Identify applications which should be managed as floating windows"; + }; + floating_layer_behaviour = lib.mkOption { + type = (lib.types.nullOr floatingLayerBehaviour); + default = null; + description = "Determines what happens on a new window when on the `FloatingLayer`\n(default: Tile)"; + }; + floating_layer_placement = lib.mkOption { + type = (lib.types.nullOr placement); + default = null; + description = "Determines the `Placement` to be used when spawning a window on the floating layer with the\n`FloatingLayerBehaviour` set to `FloatingLayerBehaviour::Float` (default: Center)"; + }; + floating_window_aspect_ratio = lib.mkOption { + type = ( + lib.types.nullOr ( + lib.types.oneOf [ + (lib.types.enum [ + "Ultrawide" + "Widescreen" + "Standard" + ]) + (lib.types.listOf lib.types.int) + ] + ) + ); + default = null; + description = "Identify applications which are slow to send initial event notifications\nAspect ratio to resize with when toggling floating mode for a window"; + }; + global_work_area_offset = lib.mkOption { + type = (lib.types.nullOr rect); + default = null; + description = "Global work area (space used for tiling) offset (default: None)"; + }; + ignore_rules = lib.mkOption { + type = (lib.types.nullOr (lib.types.listOf matchingRule)); + default = null; + description = "Individual window floating rules"; + }; + layered_applications = lib.mkOption { + type = (lib.types.nullOr (lib.types.listOf matchingRule)); + default = null; + description = "Identify applications that have the WS_EX_LAYERED extended window style"; + }; + manage_rules = lib.mkOption { + type = (lib.types.nullOr (lib.types.listOf matchingRule)); + default = null; + description = "Individual window force-manage rules"; + }; + monitors = lib.mkOption { + type = ( + lib.types.nullOr ( + lib.types.listOf ( + lib.types.submodule { + options = { + container_padding = lib.mkOption { + type = (lib.types.nullOr lib.types.int); + default = null; + description = "Container padding (default: global)"; + }; + floating_layer_behaviour = lib.mkOption { + type = (lib.types.nullOr floatingLayerBehaviour); + default = null; + description = "Determine what happens to a new window when the Floating workspace layer is active (default: Tile)"; + }; + wallpaper = lib.mkOption { + type = (lib.types.nullOr wallpaper); + default = null; + description = "Specify a wallpaper for this monitor"; + }; + window_based_work_area_offset = lib.mkOption { + type = (lib.types.nullOr rect); + default = null; + description = "Window based work area offset (default: None)"; + }; + window_based_work_area_offset_limit = lib.mkOption { + type = (lib.types.nullOr lib.types.int); + default = null; + description = "Open window limit after which the window based work area offset will no longer be applied (default: 1)"; + }; + window_hiding_position = lib.mkOption { + type = ( + lib.types.nullOr ( + lib.types.enum [ + "BottomLeft" + "BottomRight" + ] + ) + ); + default = null; + description = "Determine which position windows should be hidden at on this monitor"; + }; + work_area_offset = lib.mkOption { + type = (lib.types.nullOr rect); + default = null; + description = "Monitor-specific work area offset (default: None)"; + }; + workspace_padding = lib.mkOption { + type = (lib.types.nullOr lib.types.int); + default = null; + description = "Workspace padding (default: global)"; + }; + workspaces = lib.mkOption { + type = ( + lib.types.listOf ( + lib.types.submodule { + options = { + apply_window_based_work_area_offset = lib.mkOption { + type = (lib.types.nullOr lib.types.bool); + default = null; + description = "Apply this monitor's window-based work area offset (default: true)"; + }; + container_padding = lib.mkOption { + type = (lib.types.nullOr lib.types.int); + default = null; + description = "Container padding (default: global)"; + }; + float_override = lib.mkOption { + type = (lib.types.nullOr lib.types.bool); + default = null; + description = "Enable or disable float override, which makes it so every new window opens in floating mode (default: false)"; + }; + floating_layer_behaviour = lib.mkOption { + type = (lib.types.nullOr floatingLayerBehaviour); + default = null; + description = "Determine what happens to a new window when the Floating workspace layer is active (default: Tile)"; + }; + initial_workspace_rules = lib.mkOption { + type = (lib.types.nullOr (lib.types.listOf matchingRule)); + default = null; + description = "Initial workspace application rules"; + }; + layout = lib.mkOption { + type = (lib.types.nullOr defaultLayout); + default = null; + description = "Layout (default: BSP)"; + }; + layout_flip = lib.mkOption { + type = ( + lib.types.nullOr ( + lib.types.enum [ + "Horizontal" + "Vertical" + "HorizontalAndVertical" + ] + ) + ); + default = null; + description = "Specify an axis on which to flip the selected layout (default: None)"; + }; + layout_options = lib.mkOption { + type = ( + lib.types.nullOr ( + lib.types.submodule { + options = { + grid = lib.mkOption { + type = ( + lib.types.nullOr ( + lib.types.submodule { + options = { + rows = lib.mkOption { + type = lib.types.int; + description = "Maximum number of rows per grid column"; + }; + }; + } + ) + ); + default = null; + description = "Options related to the Grid layout"; + }; + scrolling = lib.mkOption { + type = ( + lib.types.nullOr ( + lib.types.submodule { + options = { + center_focused_column = lib.mkOption { + type = (lib.types.nullOr lib.types.bool); + default = null; + description = "With an odd number of visible columns, keep the focused window column centered"; + }; + columns = lib.mkOption { + type = lib.types.int; + description = "Desired number of visible columns (default: 3)"; + }; + }; + } + ) + ); + default = null; + description = "Options related to the Scrolling layout"; + }; + }; + } + ) + ); + default = null; + description = "Layout-specific options (default: None)"; + }; + layout_rules = lib.mkOption { + type = (lib.types.nullOr (lib.types.attrsOf defaultLayout)); + default = null; + description = "Layout rules in the format of threshold => layout (default: None)"; + }; + name = lib.mkOption { + type = lib.types.str; + description = "Name"; + }; + tile = lib.mkOption { + type = (lib.types.nullOr lib.types.bool); + default = null; + description = "Enable or disable tiling for the workspace (default: true)"; + }; + wallpaper = lib.mkOption { + type = (lib.types.nullOr wallpaper); + default = null; + description = "Specify a wallpaper for this workspace"; + }; + window_container_behaviour = lib.mkOption { + type = (lib.types.nullOr windowContainerBehaviour); + default = null; + description = "Determine what happens when a new window is opened (default: Create)"; + }; + window_container_behaviour_rules = lib.mkOption { + type = (lib.types.nullOr (lib.types.attrsOf windowContainerBehaviour)); + default = null; + description = "Window container behaviour rules in the format of threshold => behaviour (default: None)"; + }; + work_area_offset = lib.mkOption { + type = (lib.types.nullOr rect); + default = null; + description = "Workspace specific work area offset (default: None)"; + }; + workspace_padding = lib.mkOption { + type = (lib.types.nullOr lib.types.int); + default = null; + description = "Workspace padding (default: global)"; + }; + workspace_rules = lib.mkOption { + type = (lib.types.nullOr (lib.types.listOf matchingRule)); + default = null; + description = "Permanent workspace application rules"; + }; + }; + } + ) + ); + description = "Workspace configurations"; + }; + }; + } + ) + ) + ); + default = null; + description = "Monitor and workspace configurations"; + }; + mouse_follows_focus = lib.mkOption { + type = (lib.types.nullOr lib.types.bool); + default = null; + description = "Enable or disable mouse follows focus (default: true)"; + }; + object_name_change_applications = lib.mkOption { + type = (lib.types.nullOr (lib.types.listOf matchingRule)); + default = null; + description = "Identify applications that send EVENT_OBJECT_NAMECHANGE on launch (very rare)"; + }; + object_name_change_title_ignore_list = lib.mkOption { + type = (lib.types.nullOr (lib.types.listOf lib.types.str)); + default = null; + description = "Do not process EVENT_OBJECT_NAMECHANGE events as Show events for identified applications matching these title regexes"; + }; + resize_delta = lib.mkOption { + type = (lib.types.nullOr lib.types.int); + default = null; + description = "Delta to resize windows by (default 50)"; + }; + theme = lib.mkOption { + type = ( + lib.types.nullOr ( + lib.types.submodule { + options = { + palette = lib.mkOption { + type = ( + lib.types.enum [ + "Catppuccin" + "Base16" + "Custom" + ] + ); + }; + unfocused_locked_border = lib.mkOption { + type = ( + lib.types.nullOr ( + lib.types.oneOf [ + (lib.types.nullOr catppuccinValue) + (lib.types.nullOr base16Value) + ] + ) + ); + default = null; + }; + colours = lib.mkOption { + type = ( + lib.types.nullOr ( + lib.types.submodule { + options = { + base_00 = lib.mkOption { + type = colour; + }; + base_01 = lib.mkOption { + type = colour; + }; + base_02 = lib.mkOption { + type = colour; + }; + base_03 = lib.mkOption { + type = colour; + }; + base_04 = lib.mkOption { + type = colour; + }; + base_05 = lib.mkOption { + type = colour; + }; + base_06 = lib.mkOption { + type = colour; + }; + base_07 = lib.mkOption { + type = colour; + }; + base_08 = lib.mkOption { + type = colour; + }; + base_09 = lib.mkOption { + type = colour; + }; + base_0a = lib.mkOption { + type = colour; + }; + base_0b = lib.mkOption { + type = colour; + }; + base_0c = lib.mkOption { + type = colour; + }; + base_0d = lib.mkOption { + type = colour; + }; + base_0e = lib.mkOption { + type = colour; + }; + base_0f = lib.mkOption { + type = colour; + }; + }; + } + ) + ); + default = null; + }; + floating_border = lib.mkOption { + type = ( + lib.types.nullOr ( + lib.types.oneOf [ + (lib.types.nullOr catppuccinValue) + (lib.types.nullOr base16Value) + ] + ) + ); + default = null; + }; + unfocused_border = lib.mkOption { + type = ( + lib.types.nullOr ( + lib.types.oneOf [ + (lib.types.nullOr catppuccinValue) + (lib.types.nullOr base16Value) + ] + ) + ); + default = null; + }; + stack_border = lib.mkOption { + type = ( + lib.types.nullOr ( + lib.types.oneOf [ + (lib.types.nullOr catppuccinValue) + (lib.types.nullOr base16Value) + ] + ) + ); + default = null; + }; + single_border = lib.mkOption { + type = ( + lib.types.nullOr ( + lib.types.oneOf [ + (lib.types.nullOr catppuccinValue) + (lib.types.nullOr base16Value) + ] + ) + ); + default = null; + }; + bar_accent = lib.mkOption { + type = ( + lib.types.nullOr ( + lib.types.oneOf [ + (lib.types.nullOr catppuccinValue) + (lib.types.nullOr base16Value) + ] + ) + ); + default = null; + }; + name = lib.mkOption { + type = ( + lib.types.nullOr ( + lib.types.oneOf [ + (lib.types.enum [ + "Frappe" + "Latte" + "Macchiato" + "Mocha" + ]) + (lib.types.enum [ + "3024" + "Apathy" + "Apprentice" + "Ashes" + "AtelierCaveLight" + "AtelierCave" + "AtelierDuneLight" + "AtelierDune" + "AtelierEstuaryLight" + "AtelierEstuary" + "AtelierForestLight" + "AtelierForest" + "AtelierHeathLight" + "AtelierHeath" + "AtelierLakesideLight" + "AtelierLakeside" + "AtelierPlateauLight" + "AtelierPlateau" + "AtelierSavannaLight" + "AtelierSavanna" + "AtelierSeasideLight" + "AtelierSeaside" + "AtelierSulphurpoolLight" + "AtelierSulphurpool" + "Atlas" + "AyuDark" + "AyuLight" + "AyuMirage" + "Aztec" + "Bespin" + "BlackMetalBathory" + "BlackMetalBurzum" + "BlackMetalDarkFuneral" + "BlackMetalGorgoroth" + "BlackMetalImmortal" + "BlackMetalKhold" + "BlackMetalMarduk" + "BlackMetalMayhem" + "BlackMetalNile" + "BlackMetalVenom" + "BlackMetal" + "Blueforest" + "Blueish" + "Brewer" + "Bright" + "Brogrammer" + "BrushtreesDark" + "Brushtrees" + "Caroline" + "CatppuccinFrappe" + "CatppuccinLatte" + "CatppuccinMacchiato" + "CatppuccinMocha" + "Chalk" + "Circus" + "ClassicDark" + "ClassicLight" + "Codeschool" + "Colors" + "Cupcake" + "Cupertino" + "DaOneBlack" + "DaOneGray" + "DaOneOcean" + "DaOnePaper" + "DaOneSea" + "DaOneWhite" + "DanqingLight" + "Danqing" + "Darcula" + "Darkmoss" + "Darktooth" + "Darkviolet" + "Decaf" + "DefaultDark" + "DefaultLight" + "Dirtysea" + "Dracula" + "EdgeDark" + "EdgeLight" + "Eighties" + "EmbersLight" + "Embers" + "Emil" + "EquilibriumDark" + "EquilibriumGrayDark" + "EquilibriumGrayLight" + "EquilibriumLight" + "Eris" + "Espresso" + "EvaDim" + "Eva" + "EvenokDark" + "EverforestDarkHard" + "Everforest" + "Flat" + "Framer" + "FruitSoda" + "Gigavolt" + "Github" + "GoogleDark" + "GoogleLight" + "Gotham" + "GrayscaleDark" + "GrayscaleLight" + "Greenscreen" + "Gruber" + "GruvboxDarkHard" + "GruvboxDarkMedium" + "GruvboxDarkPale" + "GruvboxDarkSoft" + "GruvboxLightHard" + "GruvboxLightMedium" + "GruvboxLightSoft" + "GruvboxMaterialDarkHard" + "GruvboxMaterialDarkMedium" + "GruvboxMaterialDarkSoft" + "GruvboxMaterialLightHard" + "GruvboxMaterialLightMedium" + "GruvboxMaterialLightSoft" + "Hardcore" + "Harmonic16Dark" + "Harmonic16Light" + "HeetchLight" + "Heetch" + "Helios" + "Hopscotch" + "HorizonDark" + "HorizonLight" + "HorizonTerminalDark" + "HorizonTerminalLight" + "HumanoidDark" + "HumanoidLight" + "IaDark" + "IaLight" + "Icy" + "Irblack" + "Isotope" + "Jabuti" + "Kanagawa" + "Katy" + "Kimber" + "Lime" + "Macintosh" + "Marrakesh" + "Materia" + "MaterialDarker" + "MaterialLighter" + "MaterialPalenight" + "MaterialVivid" + "Material" + "MeasuredDark" + "MeasuredLight" + "MellowPurple" + "MexicoLight" + "Mocha" + "Monokai" + "Moonlight" + "Mountain" + "Nebula" + "NordLight" + "Nord" + "Nova" + "Ocean" + "Oceanicnext" + "OneLight" + "OnedarkDark" + "Onedark" + "OutrunDark" + "OxocarbonDark" + "OxocarbonLight" + "Pandora" + "PapercolorDark" + "PapercolorLight" + "Paraiso" + "Pasque" + "Phd" + "Pico" + "Pinky" + "Pop" + "Porple" + "PreciousDarkEleven" + "PreciousDarkFifteen" + "PreciousLightWarm" + "PreciousLightWhite" + "PrimerDarkDimmed" + "PrimerDark" + "PrimerLight" + "Purpledream" + "Qualia" + "Railscasts" + "Rebecca" + "RosePineDawn" + "RosePineMoon" + "RosePine" + "Saga" + "Sagelight" + "Sakura" + "Sandcastle" + "SelenizedBlack" + "SelenizedDark" + "SelenizedLight" + "SelenizedWhite" + "Seti" + "ShadesOfPurple" + "ShadesmearDark" + "ShadesmearLight" + "Shapeshifter" + "SilkDark" + "SilkLight" + "Snazzy" + "SolarflareLight" + "Solarflare" + "SolarizedDark" + "SolarizedLight" + "Spaceduck" + "Spacemacs" + "Sparky" + "StandardizedDark" + "StandardizedLight" + "Stella" + "StillAlive" + "Summercamp" + "SummerfruitDark" + "SummerfruitLight" + "SynthMidnightDark" + "SynthMidnightLight" + "Tango" + "Tarot" + "Tender" + "TerracottaDark" + "Terracotta" + "TokyoCityDark" + "TokyoCityLight" + "TokyoCityTerminalDark" + "TokyoCityTerminalLight" + "TokyoNightDark" + "TokyoNightLight" + "TokyoNightMoon" + "TokyoNightStorm" + "TokyoNightTerminalDark" + "TokyoNightTerminalLight" + "TokyoNightTerminalStorm" + "TokyodarkTerminal" + "Tokyodark" + "TomorrowNightEighties" + "TomorrowNight" + "Tomorrow" + "Tube" + "Twilight" + "UnikittyDark" + "UnikittyLight" + "UnikittyReversible" + "Uwunicorn" + "Vesper" + "Vice" + "Vulcan" + "Windows10Light" + "Windows10" + "Windows95Light" + "Windows95" + "WindowsHighcontrastLight" + "WindowsHighcontrast" + "WindowsNtLight" + "WindowsNt" + "Woodland" + "XcodeDusk" + "Zenbones" + "Zenburn" + ]) + ] + ) + ); + default = null; + }; + monocle_border = lib.mkOption { + type = ( + lib.types.nullOr ( + lib.types.oneOf [ + (lib.types.nullOr catppuccinValue) + (lib.types.nullOr base16Value) + ] + ) + ); + default = null; + }; + }; + } + ) + ); + default = null; + description = "Theme configuration options"; + }; + toggle_float_placement = lib.mkOption { + type = (lib.types.nullOr placement); + default = null; + description = "Determines the placement of a new window when toggling to float (default: CenterAndResize)"; + }; + tray_and_multi_window_applications = lib.mkOption { + type = (lib.types.nullOr (lib.types.listOf matchingRule)); + default = null; + description = "Identify tray and multi-window applications"; + }; + unmanaged_window_operation_behaviour = lib.mkOption { + type = ( + lib.types.nullOr ( + lib.types.enum [ + "Op" + "NoOp" + ] + ) + ); + default = null; + description = "Determine what happens when commands are sent while an unmanaged window is in the foreground (default: Op)"; + }; + window_container_behaviour = lib.mkOption { + type = (lib.types.nullOr windowContainerBehaviour); + default = null; + description = "Determine what happens when a new window is opened (default: Create)"; + }; + }; + }; + default = { }; + description = "komorebi for Mac configuration"; + }; +} diff --git a/nix/tests/default.nix b/nix/tests/default.nix new file mode 100644 index 00000000..579c21a4 --- /dev/null +++ b/nix/tests/default.nix @@ -0,0 +1,74 @@ +# E2E test harness for validating generated Nix options +# Run with: nix build -f nix/tests/default.nix +# Or via flake: nix flake check (runs as part of checks) +{ + pkgs ? import { }, +}: +let + lib = pkgs.lib; + + # Recursively filter out null values and empty attrs from a config + # This is needed because the Nix module system uses null for unset optional fields, + # but the JSON schema expects those fields to be absent entirely + filterNulls = + value: + if value == null then + null + else if builtins.isList value then + map filterNulls (builtins.filter (x: x != null) value) + else if builtins.isAttrs value then + let + filtered = lib.filterAttrs (_n: v: v != null) (builtins.mapAttrs (_n: v: filterNulls v) value); + in + filtered + else + value; + + # Helper to evaluate a config module and extract the config value + evalConfig = + optionsModule: configModule: configPath: + let + evaluated = lib.evalModules { + modules = [ + optionsModule + configModule + ]; + }; + rawConfig = lib.getAttrFromPath configPath evaluated.config; + in + filterNulls rawConfig; + + komorebiOptions = import ../komorebi-options.nix; + komorebiBarOptions = import ../komorebi-bar-options.nix; + + komorebiExample = import ./komorebi-example.nix; + komorebiBarExample = import ./komorebi-bar-example.nix; + + configs = { + komorebi-example = evalConfig komorebiOptions komorebiExample [ "komorebi" ]; + komorebi-bar-example = evalConfig komorebiBarOptions komorebiBarExample [ "komorebi-bar" ]; + }; + + komorebiJson = pkgs.writeText "komorebi-example.json" (builtins.toJSON configs.komorebi-example); + komorebiBarJson = pkgs.writeText "komorebi-bar-example.json" ( + builtins.toJSON configs.komorebi-bar-example + ); + + schemaPath = ../../schema.json; + barSchemaPath = ../../schema.bar.json; + +in +pkgs.runCommand "nix-options-validation" + { + nativeBuildInputs = [ pkgs.check-jsonschema ]; + } + '' + echo "Validating komorebi config against schema..." + check-jsonschema --schemafile ${schemaPath} ${komorebiJson} + + echo "Validating komorebi-bar config against schema..." + check-jsonschema --schemafile ${barSchemaPath} ${komorebiBarJson} + + echo "All validations passed!" + touch $out + '' diff --git a/nix/tests/komorebi-bar-example.nix b/nix/tests/komorebi-bar-example.nix new file mode 100644 index 00000000..ffb7091d --- /dev/null +++ b/nix/tests/komorebi-bar-example.nix @@ -0,0 +1,71 @@ +# Nix equivalent of docs/komorebi.bar.example.json +# This tests that users can write the exact same config in Nix +{ ... }: +{ + komorebi-bar = { + monitor = 0; + font_family = "JetBrainsMono Nerd Font"; + height = 30.0; + + theme = { + palette = "Base16"; + name = "Ashes"; + accent = "Base0D"; + }; + + left_widgets = [ + { + Komorebi = { + workspaces = { + enable = true; + hide_empty_workspaces = false; + }; + layout = { + enable = true; + }; + focused_container = { + enable = true; + show_icon = true; + }; + }; + } + ]; + + right_widgets = [ + { + Update = { + enable = true; + }; + } + { + Storage = { + enable = true; + }; + } + { + Memory = { + enable = true; + }; + } + { + Network = { + enable = true; + show_activity = true; + show_total_activity = true; + }; + } + { + Date = { + enable = true; + format = "DayDateMonthYear"; + }; + } + { + Time = { + enable = true; + format = "TwentyFourHour"; + }; + } + ]; + }; +} diff --git a/nix/tests/komorebi-example.nix b/nix/tests/komorebi-example.nix new file mode 100644 index 00000000..31e89b48 --- /dev/null +++ b/nix/tests/komorebi-example.nix @@ -0,0 +1,59 @@ +# Nix equivalent of docs/komorebi.example.json +# This tests that users can write the exact same config in Nix +{ ... }: +{ + komorebi = { + app_specific_configuration_path = "$HOME/.config/komorebi/applications.json"; + cross_monitor_move_behaviour = "Insert"; + default_workspace_padding = 15; + default_container_padding = 15; + border = true; + border_width = 6; + border_offset = 5; + floating_window_aspect_ratio = "Widescreen"; + floating_layer_behaviour = "Float"; + resize_delta = 100; + ignore_rules = [ ]; + floating_applications = [ ]; + manage_rules = [ ]; + monitors = [ + { + workspaces = [ + { + name = "I"; + layout = "BSP"; + initial_workspace_rules = [ ]; + } + { + name = "II"; + layout = "VerticalStack"; + } + { + name = "III"; + layout = "HorizontalStack"; + } + { + name = "IV"; + layout = "UltrawideVerticalStack"; + } + { + name = "V"; + layout = "Rows"; + } + { + name = "VI"; + layout = "Grid"; + } + { + name = "VII"; + layout = "RightMainVerticalStack"; + } + { + name = "VIII"; + layout = "Scrolling"; + } + ]; + } + ]; + }; +}