HASH acdc0c573604
DATE 2025-04-22
SUBJECT aerospace: add window-rules option
FILES 5 CHANGED
HASH acdc0c573604
DATE 2025-04-22
SUBJECT aerospace: add window-rules option
FILES 5 CHANGED
┌─ modules/darwin/default.nix ───────────────────────────────────────────────┐
│ diff --git a/modules/darwin/default.nix b/modules/darwin/default.nix │
│ index 4a1396a..d7cfe8a 100644 │
│ --- a/modules/darwin/default.nix │
│ +++ b/modules/darwin/default.nix │
│ @@ -11,7 +11,7 @@ in { │
│ ./system.nix │
│ ./networking.nix │
│ ./security.nix │
│ - ./homebrew.nix │
│ + ./packages.nix │
│ ./fonts.nix │
│ ./environment │
│ ]; │
└────────────────────────────────────────────────────────────────────────────────────┘
┌─ modules/darwin/default.nix ─────────┐
│ diff --git a/modules/darwin/default.nix b/mo │
│ dules/darwin/default.nix │
│ index 4a1396a..d7cfe8a 100644 │
│ --- a/modules/darwin/default.nix │
│ +++ b/modules/darwin/default.nix │
│ @@ -11,7 +11,7 @@ in { │
│ ./system.nix │
│ ./networking.nix │
│ ./security.nix │
│ - ./homebrew.nix │
│ + ./packages.nix │
│ ./fonts.nix │
│ ./environment │
│ ]; │
└──────────────────────────────────────────────┘
┌─ modules/darwin/environment/aerospace/default.nix ─────────────────────────┐
│ diff --git a/modules/darwin/environment/aerospace/default.nix b/modules/darwin/env │
│ ironment/aerospace/default.nix │
│ index aec0dc9..289e8db 100644 │
│ --- a/modules/darwin/environment/aerospace/default.nix │
│ +++ b/modules/darwin/environment/aerospace/default.nix │
│ @@ -8,7 +8,9 @@ │
│ padding = 16; │
│ in { │
│ imports = [ │
│ + ./options.nix │
│ ./binds.nix │
│ + ./rules.nix │
│ ]; │
│ config = mkIf (environment == "aerospace") { │
│ services.aerospace = { │
└────────────────────────────────────────────────────────────────────────────────────┘
┌─ ...ronment/aerospace/default.nix ───┐
│ diff --git a/modules/darwin/environment/aero │
│ space/default.nix b/modules/darwin/environme │
│ nt/aerospace/default.nix │
│ index aec0dc9..289e8db 100644 │
│ --- a/modules/darwin/environment/aerospace/d │
│ efault.nix │
│ +++ b/modules/darwin/environment/aerospace/d │
│ efault.nix │
│ @@ -8,7 +8,9 @@ │
│ padding = 16; │
│ in { │
│ imports = [ │
│ + ./options.nix │
│ ./binds.nix │
│ + ./rules.nix │
│ ]; │
│ config = mkIf (environment == "aerospace" │
│ ) { │
│ services.aerospace = { │
└──────────────────────────────────────────────┘
┌─ modules/darwin/environment/aerospace/options.nix ─────────────────────────┐
│ diff --git a/modules/darwin/environment/aerospace/options.nix b/modules/darwin/env │
│ ironment/aerospace/options.nix │
│ new file mode 100644 │
│ index 0000000..a9f9f3c │
│ --- /dev/null │
│ +++ b/modules/darwin/environment/aerospace/options.nix │
│ @@ -0,0 +1,90 @@ │
│ +{ │
│ + lib, │
│ + config, │
│ + ... │
│ +}: let │
│ + inherit (lib) mkOption filterAttrs remove mkIf; │
│ + inherit (lib.types) submodule str nullOr bool int listOf either; │
│ + cfg = config.services.aerospace; │
│ + │
│ + conditionType = submodule { │
│ + options = { │
│ + id = mkOption { │
│ + type = nullOr str; │
│ + default = null; │
│ + description = "Application id to match"; │
│ + }; │
│ + name = mkOption { │
│ + type = nullOr str; │
│ + default = null; │
│ + description = "Application name to match"; │
│ + }; │
│ + duringStartup = mkOption { │
│ + type = bool; │
│ + default = false; │
│ + description = "Apply rule only during startup"; │
│ + }; │
│ + title = mkOption { │
│ + type = nullOr str; │
│ + default = null; │
│ + description = "Window title to match (supports regex)"; │
│ + }; │
│ + }; │
│ + }; │
│ + │
│ + windowRuleType = submodule { │
│ + options = { │
│ + conditions = mkOption { │
│ + type = conditionType; │
│ + description = "Conditions for matching window"; │
│ + }; │
│ + float = mkOption { │
│ + type = bool; │
│ + default = false; │
│ + description = "Set the window to floating"; │
│ + }; │
│ + workspace = mkOption { │
│ + type = nullOr (either int str); │
│ + default = null; │
│ + description = "Workspace to move the window to (can be a number or name l │
│ ike 'Browser1')"; │
│ + }; │
│ + }; │
│ + }; │
│ + │
│ + constructRule = rule: { │
│ + "if" = filterAttrs (_: v: v != null) { │
│ + inherit (rule.conditions) title name; │
│ + app-id = rule.conditions.id; │
│ + during-startup = │
│ + if rule.conditions.duringStartup │
│ + then true │
│ + else null; │
│ + }; │
│ + run = remove null [ │
│ + ( │
│ + if rule.float │
│ + then "layout floating" │
│ + else null │
│ + ) │
│ + ( │
│ + if rule.workspace != null │
│ + then "move-node-to-workspace ${toString rule.workspace}" │
│ + else null │
│ + ) │
│ + ]; │
│ + }; │
│ +in { │
│ + options.services.aerospace = { │
│ + window-rules = mkOption { │
│ + type = listOf windowRuleType; │
│ + default = []; │
│ + description = "Window rules for aerospace"; │
│ + }; │
│ + }; │
│ + │
│ + config = mkIf cfg.enable { │
│ + services.aerospace.settings = { │
│ + on-window-detected = map constructRule cfg.window-rules; │
│ + }; │
│ + }; │
│ +} │
└────────────────────────────────────────────────────────────────────────────────────┘
┌─ ...ronment/aerospace/options.nix ───┐
│ diff --git a/modules/darwin/environment/aero │
│ space/options.nix b/modules/darwin/environme │
│ nt/aerospace/options.nix │
│ new file mode 100644 │
│ index 0000000..a9f9f3c │
│ --- /dev/null │
│ +++ b/modules/darwin/environment/aerospace/o │
│ ptions.nix │
│ @@ -0,0 +1,90 @@ │
│ +{ │
│ + lib, │
│ + config, │
│ + ... │
│ +}: let │
│ + inherit (lib) mkOption filterAttrs remove │
│ mkIf; │
│ + inherit (lib.types) submodule str nullOr │
│ bool int listOf either; │
│ + cfg = config.services.aerospace; │
│ + │
│ + conditionType = submodule { │
│ + options = { │
│ + id = mkOption { │
│ + type = nullOr str; │
│ + default = null; │
│ + description = "Application id to ma │
│ tch"; │
│ + }; │
│ + name = mkOption { │
│ + type = nullOr str; │
│ + default = null; │
│ + description = "Application name to │
│ match"; │
│ + }; │
│ + duringStartup = mkOption { │
│ + type = bool; │
│ + default = false; │
│ + description = "Apply rule only duri │
│ ng startup"; │
│ + }; │
│ + title = mkOption { │
│ + type = nullOr str; │
│ + default = null; │
│ + description = "Window title to matc │
│ h (supports regex)"; │
│ + }; │
│ + }; │
│ + }; │
│ + │
│ + windowRuleType = submodule { │
│ + options = { │
│ + conditions = mkOption { │
│ + type = conditionType; │
│ + description = "Conditions for match │
│ ing window"; │
│ + }; │
│ + float = mkOption { │
│ + type = bool; │
│ + default = false; │
│ + description = "Set the window to fl │
│ oating"; │
│ + }; │
│ + workspace = mkOption { │
│ + type = nullOr (either int str); │
│ + default = null; │
│ + description = "Workspace to move th │
│ e window to (can be a number or name like 'B │
│ rowser1')"; │
│ + }; │
│ + }; │
│ + }; │
│ + │
│ + constructRule = rule: { │
│ + "if" = filterAttrs (_: v: v != null) { │
│ + inherit (rule.conditions) title name; │
│ + app-id = rule.conditions.id; │
│ + during-startup = │
│ + if rule.conditions.duringStartup │
│ + then true │
│ + else null; │
│ + }; │
│ + run = remove null [ │
│ + ( │
│ + if rule.float │
│ + then "layout floating" │
│ + else null │
│ + ) │
│ + ( │
│ + if rule.workspace != null │
│ + then "move-node-to-workspace ${toSt │
│ ring rule.workspace}" │
│ + else null │
│ + ) │
│ + ]; │
│ + }; │
│ +in { │
│ + options.services.aerospace = { │
│ + window-rules = mkOption { │
│ + type = listOf windowRuleType; │
│ + default = []; │
│ + description = "Window rules for aeros │
│ pace"; │
│ + }; │
│ + }; │
│ + │
│ + config = mkIf cfg.enable { │
│ + services.aerospace.settings = { │
│ + on-window-detected = map constructRul │
│ e cfg.window-rules; │
│ + }; │
│ + }; │
│ +} │
└──────────────────────────────────────────────┘
┌─ modules/darwin/environment/aerospace/rules.nix ───────────────────────────┐
│ diff --git a/modules/darwin/environment/aerospace/rules.nix b/modules/darwin/envir │
│ onment/aerospace/rules.nix │
│ new file mode 100644 │
│ index 0000000..6775db8 │
│ --- /dev/null │
│ +++ b/modules/darwin/environment/aerospace/rules.nix │
│ @@ -0,0 +1,31 @@ │
│ +{ │
│ + config, │
│ + lib, │
│ + ... │
│ +}: let │
│ + inherit (config.ooknet.workstation) default profiles; │
│ + inherit (lib) optionals elem; │
│ +in { │
│ + services.aerospace.window-rules = [ │
│ + { │
│ + conditions.id = "com.1password.1password"; │
│ + float = true; │
│ + } │
│ + { │
│ + conditions.id = "com.apple.finder"; │
│ + float = true; │
│ + } │
│ + (optionals (default.browser == "zen") { │
│ + conditions.id = "app.zen-browser.zen"; │
│ + workspace = 2; │
│ + }) │
│ + (optionals (default.terminal == "ghostty") { │
│ + conditions.id = "com.mitchell.ghostty"; │
│ + workspace = 1; │
│ + }) │
│ + (optionals (elem "communication" profiles) { │
│ + conditions.id = "dev.vencord.vesktop"; │
│ + workspace = 4; │
│ + }) │
│ + ]; │
│ +} │
└────────────────────────────────────────────────────────────────────────────────────┘
┌─ ...vironment/aerospace/rules.nix ───┐
│ diff --git a/modules/darwin/environment/aero │
│ space/rules.nix b/modules/darwin/environment │
│ /aerospace/rules.nix │
│ new file mode 100644 │
│ index 0000000..6775db8 │
│ --- /dev/null │
│ +++ b/modules/darwin/environment/aerospace/r │
│ ules.nix │
│ @@ -0,0 +1,31 @@ │
│ +{ │
│ + config, │
│ + lib, │
│ + ... │
│ +}: let │
│ + inherit (config.ooknet.workstation) defau │
│ lt profiles; │
│ + inherit (lib) optionals elem; │
│ +in { │
│ + services.aerospace.window-rules = [ │
│ + { │
│ + conditions.id = "com.1password.1passw │
│ ord"; │
│ + float = true; │
│ + } │
│ + { │
│ + conditions.id = "com.apple.finder"; │
│ + float = true; │
│ + } │
│ + (optionals (default.browser == "zen") { │
│ + conditions.id = "app.zen-browser.zen" │
│ ; │
│ + workspace = 2; │
│ + }) │
│ + (optionals (default.terminal == "ghostt │
│ y") { │
│ + conditions.id = "com.mitchell.ghostty │
│ "; │
│ + workspace = 1; │
│ + }) │
│ + (optionals (elem "communication" profil │
│ es) { │
│ + conditions.id = "dev.vencord.vesktop" │
│ ; │
│ + workspace = 4; │
│ + }) │
│ + ]; │
│ +} │
└──────────────────────────────────────────────┘
┌─ modules/darwin/packages.nix ──────────────────────────────────────────────┐
│ diff --git a/modules/darwin/homebrew.nix b/modules/darwin/packages.nix │
│ similarity index 91% │
│ rename from modules/darwin/homebrew.nix │
│ rename to modules/darwin/packages.nix │
│ index 90d2a12..c58c6e3 100644 │
│ --- a/modules/darwin/homebrew.nix │
│ +++ b/modules/darwin/packages.nix │
│ @@ -1,10 +1,12 @@ │
│ { │
│ config, │
│ lib, │
│ + pkgs, │
│ ... │
│ }: let │
│ inherit (config.ooknet.workstation) default programs; │
│ inherit (lib) optionals; │
│ + inherit (builtins) attrValues; │
│ in { │
│ homebrew = { │
│ enable = true; │
│ @@ -17,6 +19,7 @@ in { │
│ }; │
│ casks = │
│ [ │
│ + "raycast" │
│ ] │
│ ++ optionals (default.terminal == "ghostty" || programs.ghostty.enable) ["g │
│ hostty"] │
│ ++ optionals (default.browser == "firefox" || programs.firefox.enable) ["fi │
│ refox"] │
└────────────────────────────────────────────────────────────────────────────────────┘
┌─ modules/darwin/packages.nix ────────┐
│ diff --git a/modules/darwin/homebrew.nix b/m │
│ odules/darwin/packages.nix │
│ similarity index 91% │
│ rename from modules/darwin/homebrew.nix │
│ rename to modules/darwin/packages.nix │
│ index 90d2a12..c58c6e3 100644 │
│ --- a/modules/darwin/homebrew.nix │
│ +++ b/modules/darwin/packages.nix │
│ @@ -1,10 +1,12 @@ │
│ { │
│ config, │
│ lib, │
│ + pkgs, │
│ ... │
│ }: let │
│ inherit (config.ooknet.workstation) defau │
│ lt programs; │
│ inherit (lib) optionals; │
│ + inherit (builtins) attrValues; │
│ in { │
│ homebrew = { │
│ enable = true; │
│ @@ -17,6 +19,7 @@ in { │
│ }; │
│ casks = │
│ [ │
│ + "raycast" │
│ ] │
│ ++ optionals (default.terminal == "gh │
│ ostty" || programs.ghostty.enable) ["ghostty │
│ "] │
│ ++ optionals (default.browser == "fir │
│ efox" || programs.firefox.enable) ["firefox" │
│ ] │
└──────────────────────────────────────────────┘
[ BACK TO LOG ]
──────────────────────────────────────────────────────────────────────────────────────
OOKNET
────────────────────────────────────────────────
OOKNET