Files
komorebi/nix/komorebi-options.nix
T
LGUG2Z 3a3a0f8f24 feat(wm): JSON schemas, and the module's typed options
komorebi.json is described as a JSON Schema, made from the Rust types that read
it: komorebic prints the schema of komorebi.json, of an applications.json, of a
notification and of a message, and the daemon answers the same four questions on
its socket. schema.json and schema.asc.json are committed (just jsonschema).

The module's config option is typed from the schema: schemars-nixgen makes
nix/komorebi-options.nix from schema.json (just nixgen), so a layout komorebi
does not have, or a value of the wrong kind, does not evaluate. The module
writes config as a komorebi.json and gives it to the daemon with --config.
configFile and the file the module writes are checked against the schema when
the system is built. applicationSpecificConfiguration takes files from GitHub,
and there are none by default, since no community file for Plasma is known.

Two checks keep the generated files honest without the tools that make them.
schema-fresh compares the schemas with what komorebic prints, and the hash on
the first line of the options with the schema. nix-options-validation evaluates
the options against the example configuration, written in Nix and in JSON.

nixos-module-eval also evaluates the module with the sources turned off: with
applicationSpecificConfiguration.enable = false the sources are left out of the
config that is written, and with no config either there is nothing to write and
the unit passes no --config. ARCHITECTURE has the guarantee row that names the
two checks.
2026-10-28 07:20:37 -07:00

515 lines
21 KiB
Nix

# schema-sha256: 2bb6a47d645d5027d15ea70545473ac3dd417e8a2d7ac932d3c593d71a539dbd
{ lib, ... }:
let
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;
description = "Target identifier";
};
kind = lib.mkOption {
type = (
lib.types.enum [
"Exe"
"Class"
"Title"
"Path"
]
);
description = "Kind of identifier to target";
};
matching_strategy = lib.mkOption {
type = (
lib.types.nullOr (
lib.types.enum [
"Legacy"
"Equals"
"StartsWith"
"EndsWith"
"Contains"
"Regex"
"DoesNotEndWith"
"DoesNotStartWith"
"DoesNotEqual"
"DoesNotContain"
]
)
);
default = null;
description = "Matching strategy to use";
};
};
}
);
layoutOptions = (
lib.types.submodule {
options = {
column_ratios = lib.mkOption {
type = (lib.types.nullOr (lib.types.listOf (lib.types.nullOr lib.types.number)));
default = null;
description = "Column width ratios (up to MAX_RATIOS values between 0.1 and 0.9)\n\n- Used by Columns layout: ratios for each column width\n- Used by Grid layout: ratios for column widths\n- Used by BSP, VerticalStack, RightMainVerticalStack: column_ratios[0] as primary split ratio\n- Used by HorizontalStack: column_ratios[0] as primary split ratio (top area height)\n- Used by UltrawideVerticalStack: column_ratios[0] as center ratio, column_ratios[1] as left ratio\n\nColumns without a ratio share remaining space equally.\nExample: `[0.3, 0.4, 0.3]` for 30%-40%-30% columns";
};
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";
};
row_ratios = lib.mkOption {
type = (lib.types.nullOr (lib.types.listOf (lib.types.nullOr lib.types.number)));
default = null;
description = "Row height ratios (up to MAX_RATIOS values between 0.1 and 0.9)\n\n- Used by Rows layout: ratios for each row height\n- Used by Grid layout: ratios for row heights\n\nRows without a ratio share remaining space equally.\nExample: `[0.5, 0.5]` for 50%-50% rows";
};
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";
};
};
}
);
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;
description = "Height of the rectangle (from the top point)";
};
left = lib.mkOption {
type = lib.types.int;
description = "Left point of the rectangle";
};
right = lib.mkOption {
type = lib.types.int;
description = "Width of the recentangle (from the left point)";
};
top = lib.mkOption {
type = lib.types.int;
description = "Top point of the rectangle";
};
};
}
);
windowContainerBehaviour = (
lib.types.enum [
"Create"
"Append"
]
);
in
{
options.komorebi = lib.mkOption {
type = lib.types.submodule {
options = {
app_specific_configuration_path = lib.mkOption {
type = (
lib.types.nullOr (
lib.types.oneOf [
pathBuf
(lib.types.listOf pathBuf)
]
)
);
default = null;
description = "Path to an applications.json, or a list of them, with rules for the applications that\nneed them: which windows to ignore, to manage and to float";
};
cross_boundary_behaviour = lib.mkOption {
type = (
lib.types.nullOr (
lib.types.enum [
"Workspace"
"Monitor"
]
)
);
default = "Monitor";
description = "Determine what happens when an action is called on a window at a monitor boundary";
};
cross_monitor_move_behaviour = lib.mkOption {
type = (
lib.types.nullOr (
lib.types.enum [
"Swap"
"Insert"
"NoOp"
]
)
);
default = "Swap";
description = "Determine what happens when a window is moved across a monitor boundary";
};
default_container_padding = lib.mkOption {
type = (lib.types.nullOr lib.types.int);
default = 5;
description = "Global default container padding";
};
default_workspace_padding = lib.mkOption {
type = (lib.types.nullOr lib.types.int);
default = 5;
description = "Global default workspace padding";
};
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 = false;
description = "Enable or disable float override, which makes it so every new window opens in floating mode";
};
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";
};
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";
};
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 = "Tile";
description = "Determines what happens on a new window when on the `FloatingLayer`";
};
floating_layer_placement = lib.mkOption {
type = (lib.types.nullOr placement);
default = "Center";
description = "Determines the `Placement` to be used when spawning a window on the floating layer with the\n`FloatingLayerBehaviour` set to `FloatingLayerBehaviour::Float`";
};
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 = "Aspect 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";
};
ignore_rules = lib.mkOption {
type = (lib.types.nullOr (lib.types.listOf matchingRule));
default = null;
description = "Individual window floating rules";
};
layout_defaults = lib.mkOption {
type = (
lib.types.nullOr (
lib.types.attrsOf (
lib.types.submodule {
options = {
layout_options = lib.mkOption {
type = (lib.types.nullOr layoutOptions);
default = null;
description = "Default layout options for this layout";
};
layout_options_rules = lib.mkOption {
type = (lib.types.nullOr (lib.types.attrsOf layoutOptions));
default = null;
description = "Threshold-based layout options rules in the format of threshold => options.\nWhen container count >= threshold, the highest matching threshold's options\nfully replace the base `layout_options`.";
};
};
}
)
)
);
default = null;
description = "Per-layout default options and rules, keyed by layout name.\nApplied as fallback when a workspace does not define its own layout_options or layout_options_rules.\nIf a workspace defines either setting, all global defaults for that layout are completely replaced.";
};
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";
};
floating_layer_behaviour = lib.mkOption {
type = (lib.types.nullOr floatingLayerBehaviour);
default = "Tile";
description = "Determine what happens to a new window when the Floating workspace layer is active";
};
window_based_work_area_offset = lib.mkOption {
type = (lib.types.nullOr rect);
default = null;
description = "Window based work area offset";
};
window_based_work_area_offset_limit = lib.mkOption {
type = (lib.types.nullOr lib.types.int);
default = 1;
description = "Open window limit after which the window based work area offset will no longer be applied";
};
window_hiding_position = lib.mkOption {
type = (
lib.types.nullOr (
lib.types.enum [
"BottomLeft"
"BottomRight"
]
)
);
default = null;
description = "Accepted so that a configuration written for another platform loads, and ignored: there is\nno hiding position on KDE Plasma";
};
work_area_offset = lib.mkOption {
type = (lib.types.nullOr rect);
default = null;
description = "Monitor-specific work area offset";
};
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 = true;
description = "Apply this monitor's window-based work area offset";
};
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 = false;
description = "Enable or disable float override, which makes it so every new window opens in floating mode";
};
floating_layer_behaviour = lib.mkOption {
type = (lib.types.nullOr floatingLayerBehaviour);
default = "Tile";
description = "Determine what happens to a new window when the Floating workspace layer is active";
};
layout = lib.mkOption {
type = (lib.types.nullOr defaultLayout);
default = "BSP";
description = "Layout";
};
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";
};
layout_options = lib.mkOption {
type = (lib.types.nullOr layoutOptions);
default = null;
description = "Layout-specific options";
};
layout_options_rules = lib.mkOption {
type = (lib.types.nullOr (lib.types.attrsOf layoutOptions));
default = null;
description = "Threshold-based layout options rules in the format of threshold => options.\nWhen container count >= threshold, the highest matching threshold's options\nfully replace the base `layout_options`.\nThis follows the same threshold logic as `layout_rules`.";
};
layout_rules = lib.mkOption {
type = (lib.types.nullOr (lib.types.attrsOf defaultLayout));
default = null;
description = "Layout rules in the format of threshold => layout";
};
name = lib.mkOption {
type = lib.types.str;
description = "Name";
};
tile = lib.mkOption {
type = (lib.types.nullOr lib.types.bool);
default = true;
description = "Enable or disable tiling for the workspace";
};
window_container_behaviour = lib.mkOption {
type = (lib.types.nullOr windowContainerBehaviour);
default = "Create";
description = "Determine what happens when a new window is opened";
};
window_container_behaviour_rules = lib.mkOption {
type = (lib.types.nullOr (lib.types.attrsOf windowContainerBehaviour));
default = null;
description = "Window container behavior rules in the format of threshold => behavior";
};
work_area_offset = lib.mkOption {
type = (lib.types.nullOr rect);
default = null;
description = "Workspace specific work area offset";
};
work_area_offset_rules = lib.mkOption {
type = (lib.types.nullOr (lib.types.attrsOf rect));
default = null;
description = "Work area offset rules in the format of threshold => Rect (default: None)";
};
workspace_padding = lib.mkOption {
type = (lib.types.nullOr lib.types.int);
default = null;
description = "Workspace padding (default: global)";
};
};
}
)
);
description = "Workspace configurations";
};
};
}
)
)
);
default = null;
description = "Monitor and workspace configurations";
};
monocle_focus_behaviour = lib.mkOption {
type = (
lib.types.nullOr (
lib.types.enum [
"Cycle"
"NoOp"
]
)
);
default = "NoOp";
description = "Determine what happens when focusing in a direction while a monocle container is active";
};
mouse_follows_focus = lib.mkOption {
type = (lib.types.nullOr lib.types.bool);
default = true;
description = "Enable or disable mouse follows focus";
};
resize_delta = lib.mkOption {
type = (lib.types.nullOr lib.types.int);
default = 50;
description = "Delta to resize windows by";
};
tabbed_applications = lib.mkOption {
type = (lib.types.nullOr (lib.types.listOf lib.types.str));
default = null;
description = "Accepted so that a configuration written for another platform loads, and ignored: a KWin\nwindow has no native tabs";
};
titleless_applications = lib.mkOption {
type = (lib.types.nullOr (lib.types.listOf lib.types.str));
default = null;
description = "Accepted so that a configuration written for another platform loads, and ignored: a KWin\nwindow is always a window";
};
toggle_float_placement = lib.mkOption {
type = (lib.types.nullOr placement);
default = "CenterAndResize";
description = "Determines the placement of a new window when toggling to float";
};
unmanaged_window_operation_behaviour = lib.mkOption {
type = (
lib.types.nullOr (
lib.types.enum [
"Op"
"NoOp"
]
)
);
default = "Op";
description = "Determine what happens when commands are sent while an unmanaged window is in the foreground";
};
window_container_behaviour = lib.mkOption {
type = (lib.types.nullOr windowContainerBehaviour);
default = "Create";
description = "Determine what happens when a new window is opened";
};
};
};
default = { };
description = "komorebi for KDE Plasma configuration";
};
}