dotfiles/machines/common/darwin/default.nix

163 lines
5.5 KiB
Nix
Raw Normal View History

2024-05-31 03:48:46 +02:00
{
config,
pkgs,
lib,
...
}:
{
2024-05-07 18:20:52 +02:00
imports = [ ./options.nix ];
2023-05-29 14:10:26 +02:00
# manipulate the global /etc/zshenv for PATH, etc.
programs.zsh.enable = true;
system.stateVersion = 4;
security.pam.enableSudoTouchIdAuth = true;
system.defaults.alf.stealthenabled = 1;
# Auto upgrade nix package and the daemon service.
services.nix-daemon.enable = true;
2023-06-02 22:55:36 +02:00
2024-05-30 20:02:02 +02:00
nix.linux-builder.enable = true;
2023-06-02 22:55:36 +02:00
services = {
2024-05-31 03:10:39 +02:00
sketchybar = {
enable = true;
extraPackages = with pkgs; [
jankyborders
nushell
];
2024-05-31 03:10:39 +02:00
};
2023-06-02 22:55:36 +02:00
yabai = {
enable = true;
enableScriptingAddition = true;
logFile = "/var/tmp/yabai.log";
config = {
layout = "bsp";
2024-05-31 03:48:46 +02:00
window_gap = 7;
2023-06-02 22:55:36 +02:00
left_padding = 5;
right_padding = 5;
top_padding = 5;
bottom_padding = 5;
window_animation_duration = "0.3";
window_origin_display = "cursor";
2023-06-02 22:55:36 +02:00
window_placement = "second_child";
window_shadow = "float";
mouse_modifier = "cmd";
mouse_action2 = "resize";
mouse_drop_action = "swap";
mouse_follows_focus = "off";
focus_follows_mouse = "off";
2024-05-31 03:48:46 +02:00
external_bar = "all:32:0";
2023-06-02 22:55:36 +02:00
};
2024-05-07 18:20:52 +02:00
extraConfig =
let
rule = "yabai -m rule";
mkRules =
apps: options:
builtins.concatStringsSep "\n" (map (app: ''yabai -m rule --add app="${app}" ${options}'') apps);
unmanaged = apps: mkRules apps "manage=off";
in
''
# auto-inject scripting additions
yabai -m signal --add event=dock_did_restart action="sudo yabai --load-sa"
sudo yabai --load-sa
2023-06-02 22:55:36 +02:00
2024-05-07 18:20:52 +02:00
# ensure that there are always 10 spaces
spacestocreate=10
spaces=$((spacestocreate - $(yabai -m query --spaces | ${pkgs.jq}/bin/jq length)))
while [ "$spaces" -gt 0 ]; do
yabai -m space --create
spaces=$((spaces - 1))
done
2023-06-02 22:55:36 +02:00
2024-05-07 18:20:52 +02:00
# make the spaces auto-balance
for i in {1..10}; do
yabai -m config --space "$i" auto_balance on
done
2024-05-07 18:20:52 +02:00
${unmanaged [
"CleanShot"
"GOG Galaxy"
"Godot"
"JetBrains Toolbox"
"Mullvad VPN"
"OBS Studio"
"Sip"
"Steam"
"System Settings"
"iStat Menus"
]}
2024-05-26 01:32:52 +02:00
# os rules
2024-05-07 18:20:52 +02:00
${rule} --add label="Finder" app="^Finder$" title="(Co(py|nnect)|Move|Info|Pref)" manage=off
${rule} --add label="Safari" app="^Safari$" title="^(General|(Tab|Password|Website|Extension)s|AutoFill|Se(arch|curity)|Privacy|Advance)$" manage=off
2024-05-26 01:32:52 +02:00
${rule} --add label="Orion" app="^Orion$" title="^(General|Appearance|Tabs|Browsing|Sync|Passwords|Privacy|Search|Websites|Advanced|Plus)$" manage=off
# dev rules
${rule} --add label="Dash" app="^Dash$" title="^(General|Downloads|Docsets|Web Search|Integration|Snippets)$" manage=off
${rule} --add label="JetBrains IDE Settings" app="^(CLion|GoLand|PhpStorm|IntelliJ IDEA|PyCharm|RubyMine|RustRover|WebStorm)$" title="^(Settings|Run\/Debug Configurations|Remote Development|Welcome.+|Keyboard Shortcut|Rename|Clear Read-Only Status)$" manage=off
2024-05-07 18:20:52 +02:00
'';
2023-06-02 22:55:36 +02:00
};
skhd = {
enable = true;
2024-05-07 18:20:52 +02:00
skhdConfig =
let
mapKeymaps =
cmd:
builtins.concatStringsSep "\n" (
map (i: builtins.replaceStrings [ "Num" ] [ (toString (if (i == 10) then 0 else i)) ] cmd) (
lib.range 1 10
)
);
in
''
#!/usr/bin/env sh
# focus window
cmd + ctrl - h : yabai -m window --focus west
cmd + ctrl - j : yabai -m window --focus south
cmd + ctrl - k : yabai -m window --focus north
cmd + ctrl - l : yabai -m window --focus east
# move window
cmd + shift - h : yabai -m window --warp west
cmd + shift - j : yabai -m window --warp south
cmd + shift - k : yabai -m window --warp north
cmd + shift - l : yabai -m window --warp east
# toggle sticky/floating
cmd + shift - s: yabai -m window --toggle sticky --toggle float --toggle topmost
cmd + shift - d: yabai -m window --toggle float
# rotate
cmd + ctrl - e : yabai -m space --balance
cmd + ctrl - r : yabai -m space --rotate 270
# open terminal
cmd + shift - return : open -na "''${HOME}/Applications/Home Manager Apps/WezTerm.app"
# restart yabai
cmd + alt - r : brew services restart yabai
2023-06-02 22:55:36 +02:00
2024-05-07 18:20:52 +02:00
# ONLY WORKS WITH SIP DISABLED:
# fast focus space left/right
ctrl - left : yabai -m space --focus prev
ctrl - right : yabai -m space --focus next
# switch to space
${mapKeymaps "cmd + ctrl - Num : yabai -m space --focus Num"}
# send window to desktop, follow focus, and move out of scratchpad
${mapKeymaps "cmd + shift - Num : yabai -m window --space Num; yabai -m space --focus Num; yabai -m window --scratchpad ''"}
2024-05-07 18:20:52 +02:00
cmd - tab : yabai -m window --toggle main
cmd + shift - tab : yabai -m window --scratchpad main
'';
2023-06-02 22:55:36 +02:00
};
};
2024-05-31 03:48:46 +02:00
environment.systemPackages = [ pkgs.jankyborders ];
launchd.user.agents.jankyborders.serviceConfig = {
ProgramArguments = [ "${pkgs.jankyborders}/bin/borders" ];
KeepAlive = true;
RunAtLoad = true;
EnvironmentVariables.PATH = "${pkgs.jankyborders}/bin:${config.environment.systemPath}";
};
2023-05-29 14:10:26 +02:00
}