1
0
Fork 0
mirror of https://github.com/LnL7/nix-darwin.git synced 2025-03-06 08:47:00 +00:00
nix-darwin/modules/services/aerospace/default.nix

164 lines
5.3 KiB
Nix
Raw Normal View History

2024-10-13 12:52:55 +01:00
{
config,
lib,
pkgs,
...
}:
let
cfg = config.services.aerospace;
format = pkgs.formats.toml { };
configFile = format.generate "aerospace.toml" cfg.settings;
in
{
2024-10-17 23:30:31 +01:00
options = {
services.aerospace = with lib.types; {
enable = lib.mkEnableOption "AeroSpace window manager";
2024-10-13 12:52:55 +01:00
2024-10-17 23:30:31 +01:00
package = lib.mkPackageOption pkgs "aerospace" { };
2024-10-13 12:52:55 +01:00
2024-10-17 23:30:31 +01:00
settings = lib.mkOption {
2024-10-13 12:52:55 +01:00
type = submodule {
freeformType = format.type;
options = {
2024-10-17 23:30:31 +01:00
start-at-login = lib.mkOption {
type = bool;
2024-10-13 12:52:55 +01:00
default = false;
description = "Do not start AeroSpace at login. (Managed by launchd instead)";
};
2024-10-17 23:30:31 +01:00
after-login-command = lib.mkOption {
type = listOf str;
2024-10-13 12:52:55 +01:00
default = [ ];
description = "Do not use AeroSpace to run commands after login. (Managed by launchd instead)";
};
2024-10-17 23:30:31 +01:00
after-startup-command = lib.mkOption {
type = listOf str;
2024-10-13 12:52:55 +01:00
default = [ ];
description = "Do not use AeroSpace to run commands after startup. (Managed by launchd instead)";
};
2024-10-17 23:30:31 +01:00
enable-normalization-flatten-containers = lib.mkOption {
2024-10-13 12:52:55 +01:00
type = bool;
default = true;
description = "Containers that have only one child are \"flattened\".";
};
2024-10-17 23:30:31 +01:00
enable-normalization-opposite-orientation-for-nested-containers = lib.mkOption {
2024-10-13 12:52:55 +01:00
type = bool;
default = true;
description = "Containers that nest into each other must have opposite orientations.";
};
2024-10-17 23:30:31 +01:00
accordion-padding = lib.mkOption {
2024-10-13 12:52:55 +01:00
type = int;
default = 30;
description = "Padding between windows in an accordion container.";
};
2024-10-17 23:30:31 +01:00
default-root-container-layout = lib.mkOption {
2024-10-13 12:52:55 +01:00
type = enum [
"tiles"
"accordion"
];
default = "tiles";
description = "Default layout for the root container.";
};
2024-10-17 23:30:31 +01:00
default-root-container-orientation = lib.mkOption {
2024-10-13 12:52:55 +01:00
type = enum [
"horizontal"
"vertical"
"auto"
];
default = "auto";
description = "Default orientation for the root container.";
};
2024-10-17 23:30:31 +01:00
on-window-detected = lib.mkOption {
2024-10-13 12:52:55 +01:00
type = listOf str;
default = [ ];
description = "Commands to run every time a new window is detected.";
};
2024-10-17 23:30:31 +01:00
on-focus-changed = lib.mkOption {
2024-10-13 12:52:55 +01:00
type = listOf str;
default = [ ];
description = "Commands to run every time focused window or workspace changes.";
};
2024-10-17 23:30:31 +01:00
on-focused-monitor-changed = lib.mkOption {
2024-10-13 12:52:55 +01:00
type = listOf str;
default = [ "move-mouse monitor-lazy-center" ];
description = "Commands to run every time focused monitor changes.";
};
2024-10-17 23:30:31 +01:00
exec-on-workspace-change = lib.mkOption {
2024-10-13 12:52:55 +01:00
type = listOf str;
default = [ ];
example = [
"/bin/bash"
"-c"
"sketchybar --trigger aerospace_workspace_change FOCUSED=$AEROSPACE_FOCUSED_WORKSPACE"
];
description = "Commands to run every time workspace changes.";
};
2024-10-17 23:30:31 +01:00
key-mapping.preset = lib.mkOption {
2024-10-13 12:52:55 +01:00
type = enum [
"qwerty"
"dvorak"
];
default = "qwerty";
description = "Keymapping preset.";
};
};
};
default = { };
2024-10-17 23:30:31 +01:00
example = lib.literalExpression ''
2024-10-13 12:52:55 +01:00
{
gaps = {
outer.left = 8;
outer.bottom = 8;
outer.top = 8;
outer.right = 8;
};
mode.main.binding = {
alt-h = "focus left";
alt-j = "focus down";
alt-k = "focus up";
alt-l = "focus right";
};
}
'';
description = ''
AeroSpace configuration, see
<link xlink:href="https://nikitabobko.github.io/AeroSpace/guide#configuring-aerospace"/>
for supported values.
'';
};
};
};
2024-10-17 23:30:31 +01:00
config = (
lib.mkIf (cfg.enable) {
assertions = [
{
assertion = !cfg.settings.start-at-login;
message = "AeroSpace started at login is managed by home-manager and launchd instead of itself via this option.";
}
{
assertion = cfg.settings.after-login-command == [ ];
message = "AeroSpace will not run these commands as it does not start itself.";
}
{
assertion = cfg.settings.after-startup-command == [ ];
message = "AeroSpace will not run these commands as it does not start itself.";
}
];
2024-10-13 12:52:55 +01:00
environment.systemPackages = [ cfg.package ];
2024-10-17 23:30:31 +01:00
launchd.user.agents.aerospace = {
command =
"${cfg.package}/Applications/AeroSpace.app/Contents/MacOS/AeroSpace"
+ (lib.optionalString (cfg.settings != { }) " --config-path ${configFile}");
serviceConfig = {
KeepAlive = true;
RunAtLoad = true;
};
2024-10-13 12:52:55 +01:00
};
2024-10-17 23:30:31 +01:00
}
);
2024-10-13 12:52:55 +01:00
}