yabai module in nix-darwin now generally available

By Calum MacRae

May 13, 2020

As of ~2 hours ago, a Nix module to install & configure yabai is now generally available on the master branch of nix-darwin.

I submitted a PR for a module I'd been using personally for a while which I finally decided to share.

If you follow the master branch on your macOS system, after a nix-channel --update, you can now manage yabai like so

{
  services.yabai = {
    enable = true;
    package = pkgs.yabai;
    enableScriptingAddition = true;
    config = {
      focus_follows_mouse          = "autoraise";
      mouse_follows_focus          = "off";
      window_placement             = "second_child";
      window_opacity               = "off";
      window_opacity_duration      = "0.0";
      window_border                = "on";
      window_border_placement      = "inset";
      window_border_width          = 2;
      window_border_radius         = 3;
      active_window_border_topmost = "off";
      window_topmost               = "on";
      window_shadow                = "float";
      active_window_border_color   = "0xff5c7e81";
      normal_window_border_color   = "0xff505050";
      insert_window_border_color   = "0xffd75f5f";
      active_window_opacity        = "1.0";
      normal_window_opacity        = "1.0";
      split_ratio                  = "0.50";
      auto_balance                 = "on";
      mouse_modifier               = "fn";
      mouse_action1                = "move";
      mouse_action2                = "resize";
      layout                       = "bsp";
      top_padding                  = 36;
      bottom_padding               = 10;
      left_padding                 = 10;
      right_padding                = 10;
      window_gap                   = 10;
    };

    extraConfig = ''
        # rules
        yabai -m rule --add app='System Preferences' manage=off

        # Any other arbitrary config here
      '';
    };
}

At the moment, you have to specify the services.yabai.package option. The package I submitted to nixpkgs is in the unstable channel already, so you can just specify pkgs.yabai as the value if you follow nixpkgs-unstable.

To go along with the yabai package & module, I submitted similar PRs for spacebar. The package is already available in nixpkgs-unstable, and the module in nix-darwin will soon follow.

Enjoy!

Posted on:
May 13, 2020
Length:
2 minute read, 252 words
Tags:
nix darwin
See Also:
A Nix overlay for Emacs 27 with the 'emacs-mac' patches
spacebar module in nix-darwin now generally available
Nix Generator Functions for Sway