Skip to content

Instantly share code, notes, and snippets.

@shardulbee
Created June 3, 2020 14:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save shardulbee/8d693d1e3e60048532c5f6a505282b97 to your computer and use it in GitHub Desktop.
Save shardulbee/8d693d1e3e60048532c5f6a505282b97 to your computer and use it in GitHub Desktop.
nix-darwin config
{ config, pkgs, ... }:
{
pkgsUnstable = import <nixpkgs-unstable> {};
imports = [ <home-manager/nix-darwin> ./home.nix ];
environment.darwinConfig = "${config.users.users.shardy.home}/dotfiles/darwin.nix";
system.stateVersion = 4;
environment.systemPackages = [
pkgs.alacritty
pkgs.pinentry_mac
pkgs.terminal-notifier
];
nix.useDaemon = false;
services.nix-daemon.enable = false;
nix.maxJobs = 4;
nix.buildCores = 4;
# Make sure nix-darwin overwrites /etc/zshrc otherwise your prompt will be broken
programs.zsh.enable = true;
programs.nix-index.enable = true;
# {{{ yabai
services.yabai = {
enable = true;
package = pkgsUnstable.yabai;
enableScriptingAddition = true;
config = {
# mouse stuff
mouse_modifier = "fn";
mouse_action1 = "move";
mouse_action2 = "resize";
mouse_follows_focus = "on";
focus_follows_mouse = "autoraise";
window_placement = "second_child";
window_topmost = "on";
window_shadow = "float";
split_ratio = 0.50;
auto_balance = "true";
layout = "bsp";
# default padding
top_padding = 0;
bottom_padding = 0;
left_padding = 0;
right_padding = 0;
window_gap = 0;
active_window_opacity = "1.0";
normal_window_opacity = "1.0";
};
extraConfig = ''
yabai -m rule --add app="^Google Chrome$" space=^3
yabai -m rule --add app="^Slack$" space=^7
yabai -m rule --add app="^Messages$" space=^8
yabai -m rule --add app="^Things$" space=^9
yabai -m rule --add app="^Alacritty$" space=^10
yabai -m rule --add app="^Dash.app$" manage=off topmost=on
yabai -m rule --add app="^Finder$" manage=off topmost=on
yabai -m rule --add app="^System Preferences$" manage=off topmost=on
for e in application_launched application_terminated window_created window_destroyed
do
yabai -m signal --add event=$e action="${pkgs.writeShellScript "yabai-smart-gaps" ''
spaceData=$(yabai -m query --spaces --space)
spaceWindows=( $(echo $spaceData | ${pkgs.jq}/bin/jq '.windows | .[]') )
spaceIndex=$(echo $spaceData | ${pkgs.jq}/bin/jq '.index')
windowCount=$(yabai -m query --windows \
| ${pkgs.jq}/bin/jq "[.[]|select(.role==\"AXWindow\" and .space==$spaceIndex)]|length")
if [[ $windowCount -eq 1 ]]; then
yabai -m space --padding abs:0:0:0:0
yabai -m space --gap abs:0
elif [[ $windowCount -gt 1 ]]; then
yabai -m space --padding abs:10:10:10:10
yabai -m space --gap abs:10
fi
echo "yabai config loaded"
''}"
done
'';
};
# }}}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment