Extract aerospace configuration into reusable modules
Create both home-manager and nix-darwin modules for aerospace window manager configuration, removing 110+ lines of duplicated config from machine-specific files. Changes: - Add home/modules/aerospace module with configurable leader key - Add modules/aerospace.nix for system-level macOS settings - Include autoraise configuration in home module - Update home-darwin-work.nix to use new modules - Update johno-macbookpro configuration to use system module - Remove inline aerospace/autoraise config and launchd agents
This commit is contained in:
@@ -1,8 +1,5 @@
|
||||
{ config, lib, pkgs, globalInputs, system, ... }:
|
||||
|
||||
let
|
||||
leader = "cmd"; # Change this to experiment with different leader keys (e.g., "cmd", "ctrl")
|
||||
in
|
||||
{
|
||||
# Claude Code Package Override for Corporate Work Environment
|
||||
#
|
||||
@@ -37,40 +34,11 @@ in
|
||||
|
||||
# System packages
|
||||
home.packages = with pkgs; [
|
||||
autoraise
|
||||
google-cloud-sdk
|
||||
];
|
||||
|
||||
# Note: ghostty installed via Homebrew (managed outside of nix)
|
||||
|
||||
# Auto-start autoraise on login
|
||||
launchd.agents.autoraise = {
|
||||
enable = true;
|
||||
config = {
|
||||
ProgramArguments = [
|
||||
"${pkgs.autoraise}/bin/AutoRaise"
|
||||
"-pollMillis" "50"
|
||||
"-delay" "2"
|
||||
"-focusDelay" "2"
|
||||
];
|
||||
RunAtLoad = true;
|
||||
KeepAlive = true;
|
||||
};
|
||||
};
|
||||
|
||||
# Auto-start aerospace on login
|
||||
# NOTE: In 25.11+, this can be simplified to `programs.aerospace.launchd.enable = true`
|
||||
launchd.agents.aerospace = {
|
||||
enable = true;
|
||||
config = {
|
||||
Program = "${pkgs.aerospace}/Applications/AeroSpace.app/Contents/MacOS/AeroSpace";
|
||||
RunAtLoad = true;
|
||||
KeepAlive = true;
|
||||
StandardOutPath = "/tmp/aerospace.log";
|
||||
StandardErrorPath = "/tmp/aerospace.err.log";
|
||||
};
|
||||
};
|
||||
|
||||
# Override Darwin-incompatible settings from base role
|
||||
programs.rbw.settings.pinentry = lib.mkForce pkgs.pinentry_mac;
|
||||
|
||||
@@ -152,97 +120,14 @@ in
|
||||
|
||||
home.shell.enableShellIntegration = true;
|
||||
|
||||
# TODO: Move this to its own role and/or module
|
||||
# Enable aerospace window manager with autoraise
|
||||
programs.aerospace = {
|
||||
enable = true;
|
||||
userSettings.mode.main.binding = {
|
||||
"${leader}-slash" = "layout tiles horizontal vertical";
|
||||
"${leader}-comma" = "layout accordion horizontal vertical";
|
||||
"${leader}-shift-q" = "close";
|
||||
"${leader}-shift-f" = "fullscreen";
|
||||
"${leader}-h" = "focus left";
|
||||
"${leader}-j" = "focus down";
|
||||
"${leader}-k" = "focus up";
|
||||
"${leader}-l" = "focus right";
|
||||
"${leader}-shift-h" = "move left";
|
||||
"${leader}-shift-j" = "move down";
|
||||
"${leader}-shift-k" = "move up";
|
||||
"${leader}-shift-l" = "move right";
|
||||
"${leader}-minus" = "resize smart -50";
|
||||
"${leader}-equal" = "resize smart +50";
|
||||
"${leader}-1" = "workspace 1";
|
||||
"${leader}-2" = "workspace 2";
|
||||
"${leader}-3" = "workspace 3";
|
||||
"${leader}-4" = "workspace 4";
|
||||
"${leader}-5" = "workspace 5";
|
||||
"${leader}-6" = "workspace 6";
|
||||
"${leader}-7" = "workspace 7";
|
||||
"${leader}-8" = "workspace 8";
|
||||
"${leader}-9" = "workspace 9";
|
||||
"${leader}-0" = "workspace 10";
|
||||
"${leader}-shift-1" = "move-node-to-workspace 1";
|
||||
"${leader}-shift-2" = "move-node-to-workspace 2";
|
||||
"${leader}-shift-3" = "move-node-to-workspace 3";
|
||||
"${leader}-shift-4" = "move-node-to-workspace 4";
|
||||
"${leader}-shift-5" = "move-node-to-workspace 5";
|
||||
"${leader}-shift-6" = "move-node-to-workspace 6";
|
||||
"${leader}-shift-7" = "move-node-to-workspace 7";
|
||||
"${leader}-shift-8" = "move-node-to-workspace 8";
|
||||
"${leader}-shift-9" = "move-node-to-workspace 9";
|
||||
"${leader}-shift-0" = "move-node-to-workspace 10";
|
||||
"${leader}-tab" = "workspace-back-and-forth";
|
||||
"${leader}-shift-tab" = "move-workspace-to-monitor --wrap-around next";
|
||||
|
||||
"${leader}-enter" = ''
|
||||
exec-and-forget osascript <<'APPLESCRIPT'
|
||||
tell application "Ghostty"
|
||||
activate
|
||||
tell application "System Events"
|
||||
keystroke "n" using {command down}
|
||||
end tell
|
||||
end tell
|
||||
APPLESCRIPT
|
||||
'';
|
||||
|
||||
"${leader}-shift-enter" = ''
|
||||
exec-and-forget osascript <<'APPLESCRIPT'
|
||||
tell application "Google Chrome"
|
||||
set newWindow to make new window
|
||||
activate
|
||||
tell newWindow to set index to 1
|
||||
end tell
|
||||
APPLESCRIPT
|
||||
'';
|
||||
|
||||
"${leader}-shift-e" = "exec-and-forget zsh --login -c \"emacsclient -c -n\"";
|
||||
|
||||
# Service mode: Deliberate aerospace window management
|
||||
"${leader}-i" = "mode service";
|
||||
|
||||
# Passthrough mode: Temporarily disable aerospace to use macOS shortcuts
|
||||
# Press Cmd-P, then use any macOS shortcut (like Cmd-K in Slack), then press Cmd-P again to exit
|
||||
"${leader}-p" = "mode passthrough";
|
||||
};
|
||||
|
||||
# Service mode: For deliberate aerospace window management operations
|
||||
userSettings.mode.service.binding = {
|
||||
esc = ["reload-config" "mode main"];
|
||||
r = ["flatten-workspace-tree" "mode main"]; # reset layout
|
||||
f = ["layout floating tiling" "mode main"]; # Toggle between floating and tiling layout
|
||||
backspace = ["close-all-windows-but-current" "mode main"];
|
||||
|
||||
"${leader}-shift-h" = ["join-with left" "mode main"];
|
||||
"${leader}-shift-j" = ["join-with down" "mode main"];
|
||||
"${leader}-shift-k" = ["join-with up" "mode main"];
|
||||
"${leader}-shift-l" = ["join-with right" "mode main"];
|
||||
};
|
||||
|
||||
# Passthrough mode: All shortcuts pass through to macOS
|
||||
# This mode has minimal bindings - just ways to exit back to main mode
|
||||
userSettings.mode.passthrough.binding = {
|
||||
esc = "mode main";
|
||||
"${leader}-p" = "mode main"; # Toggle back with same key (Cmd-P)
|
||||
};
|
||||
leader = "cmd";
|
||||
# Optional: Add per-machine userSettings overrides
|
||||
# userSettings = {
|
||||
# mode.main.binding."${leader}-custom" = "custom-command";
|
||||
# };
|
||||
};
|
||||
|
||||
home.roles = {
|
||||
@@ -258,5 +143,6 @@ in
|
||||
./modules/emacs
|
||||
./modules/kubectl
|
||||
./modules/tmux
|
||||
./modules/aerospace
|
||||
];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user