Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Courtesy Issue] Nix package now generally available #510

Closed
cmacrae opened this issue May 6, 2020 · 15 comments
Closed

[Courtesy Issue] Nix package now generally available #510

cmacrae opened this issue May 6, 2020 · 15 comments
Labels
documentation Documentation

Comments

@cmacrae
Copy link

cmacrae commented May 6, 2020

👋 Hope you don't mind an issue being opened for this, but I figured it was a good way to notify you and an easy way for people to discover if they were looking for Nix support:

I submitted a package for yabai to the nixpkgs repository the other day. I'm happy to say, following the merge, it is now generally available on the nixpkgs-unstable channel 🎉

$ nix-channel --list
darwin https://github.com/LnL7/nix-darwin/archive/master.tar.gz
nixpkgs https://nixos.org/channels/nixpkgs-unstable

$ nix-env -qaP --description yabai
nixpkgs.yabai  yabai-3.0.0  A tiling window manager for macOS based on binary space partitioning 

I'll aslo be submitting a Nix service module I've been using personally for a while to the LnL7/nix-darwin project. It lets you configure yabai like so:

{
  services.yabai = {
    enable = true;
    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
      '';
    };
}

Finally, I'm sure others here may be interested to know I also submitted a PR for spacebar and have a similar module ready to go, too. Once the package is generally available in the channels, I'll submit a PR for the module.

@koekeishiya @dominiklohmann Please feel free to simply close this issue - but if you'd like, I can update the documentation regarding the package (and perhaps, subsequently, the module - at a later date)

@dominiklohmann
Copy link
Collaborator

I think this would make a really good addition to the wiki.

Mind creating a draft of what you think needs to be mentioned? This can just be a rough outline / bullet points and I'll write a section from that.

@dominiklohmann dominiklohmann added the documentation Documentation label May 6, 2020
@cmacrae
Copy link
Author

cmacrae commented May 6, 2020

Sure, I'll gladly draft something up :) Do you think it's perhaps worth waiting until I've got the module merged upstream (if it's accepted) in nix-darwin?

That's the more comprehensive part (in terms of use) of these contributions. I think if we updated the documentation to simply state a Nix package is available, it may leave some users wondering where an acompanying service is

@dominiklohmann
Copy link
Collaborator

Do you think it's perhaps worth waiting until I've got the module merged upstream (if it's accepted) in nix-darwin?

People here are generally open to the idea of living on the edge and running nightly/unstable software, so I don't think it's a blocker.

@cmacrae
Copy link
Author

cmacrae commented May 6, 2020

Cool, thanks for weighing in here :) I'll take some time to draft something for the wiki a little later - I imagine it'll be fairly minimal

@cmacrae
Copy link
Author

cmacrae commented May 6, 2020

I've just submitted the service module PR to nix-darwin. LnL can be pretty snappy on this stuff, so we might even see a merge on this before I sit down and write the docs for the package anyway 🤞
LnL7/nix-darwin#196

@cmacrae
Copy link
Author

cmacrae commented May 13, 2020

It's now merged and generally available, short post on it here:
https://cmacr.ae/post/2020-05-13-yabai-module-in-nix-darwin-now-generally-available/

I'll write up a draft for docs tomorrow, as I should have some time :)

@cmacrae
Copy link
Author

cmacrae commented May 14, 2020

Wiki Draft/Outline

  • A Nix package is also available on the nixpkgs-unstable channel
  • A Nix service module is also available for users of nix-darwin
  • Example configuration
{
  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_topmost               = "on";
      window_shadow                = "float";
      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
      '';
    };
}
  • Note: The services.yabai.package option must be specified and can simply be set to pkgs.yabai. There is no default option as it is currently distributed via the unstable channel
  • Note: The services.yabai.enableScriptingAddition option only works is SIP is disabled

@cmacrae
Copy link
Author

cmacrae commented May 14, 2020

There you go @dominiklohmann :) Hopefully that's enough to go off, but please do let me know if there's stuff you feel I need to expand on

@breuerfelix
Copy link

thanks for the package! Is this currently bugged? :) I get some errors when trying to install from unstable right now on my M1

@ramnes
Copy link

ramnes commented Sep 7, 2021

Yep, looks like it depends on ghc-8.10.6 which isn't available for aarch64-darwin at the moment. Is there any workaround?

@venus-as-a-boy
Copy link

it's broken for me as well

./src/osax/payload.m:555:36: error: too many arguments to function call, expected 0, have 2
    return (uint64_t) objc_msgSend(space, @selector(spid));
                      ~~~~~~~~~~~~ ^~~~~~~~~~~~~~~~~~~~~~
/nix/store/f26dvgxlrs321kahfxy2bmdq8ap5wik3-libobjc-11.0.0/include/objc/message.h:63:1: note: 'objc_msgSend' declared here
objc_msgSend(void /* id self, SEL op, ... */ )
^
./src/osax/payload.m:560:60: error: too many arguments to function call, expected 0, have 3
    NSArray *spaces_for_display = (NSArray *) objc_msgSend(dock_spaces, @selector(spacesForDisplay:), display_uuid);
                                              ~~~~~~~~~~~~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/nix/store/f26dvgxlrs321kahfxy2bmdq8ap5wik3-libobjc-11.0.0/include/objc/message.h:63:1: note: 'objc_msgSend' declared here
objc_msgSend(void /* id self, SEL op, ... */ )
^
./src/osax/payload.m:627:5: error: unknown register name '%rdi' in asm
    asm__call_move_space(source_space, dest_space, dest_display_uuid, dock_spaces, move_space_fp);
    ^
./src/osax/payload.m:606:148: note: expanded from macro 'asm__call_move_space'
        __asm__("movq %0, %%rdi;""movq %1, %%rsi;""movq %2, %%rdx;""movq %3, %%r13;""callq *%4;" : :"r"(v0), "r"(v1), "r"(v2), "r"(v3), "r"(func) :"%rdi", "%rsi", "%rdx", "%r13");
                                                                                                                                                   ^
./src/osax/payload.m:630:22: error: too many arguments to function call, expected 0, have 5
        objc_msgSend(dp_desktop_picture_manager, @selector(moveSpace:toDisplay:displayUUID:), source_space, dest_display_id, dest_display_uuid);
        ~~~~~~~~~~~~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/nix/store/f26dvgxlrs321kahfxy2bmdq8ap5wik3-libobjc-11.0.0/include/objc/message.h:63:1: note: 'objc_msgSend' declared here
objc_msgSend(void /* id self, SEL op, ... */ )
^
./src/osax/payload.m:683:9: error: unknown register name '%rdi' in asm
        asm__call_add_space(new_space, display_space, add_space_fp);
        ^
./src/osax/payload.m:674:96: note: expanded from macro 'asm__call_add_space'
        __asm__("movq %0, %%rdi;""movq %1, %%r13;""callq *%2;" : :"r"(v0), "r"(v1), "r"(func) :"%rdi", "%r13");
                                                                                               ^
./src/osax/payload.m:694:40: error: too many arguments to function call, expected 0, have 3
        id source_space = objc_msgSend(dock_spaces, @selector(currentSpaceforDisplayUUID:), dest_display);
                          ~~~~~~~~~~~~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/nix/store/f26dvgxlrs321kahfxy2bmdq8ap5wik3-libobjc-11.0.0/include/objc/message.h:63:1: note: 'objc_msgSend' declared here
objc_msgSend(void /* id self, SEL op, ... */ )
^
6 errors generated.
make: *** [makefile:24: src/osax/sa_loader.c] Error 1
builder for '/nix/store/g91lp3ms5mnkbmgq5vy3fmqyb4s7lbjs-yabai-3.3.4.drv' failed with exit code 2

@okkdev
Copy link

okkdev commented Mar 24, 2022

Any possibility of adding something like the nix darwin module to home-manager? 😄

@cmacrae
Copy link
Author

cmacrae commented Mar 24, 2022

Any possibility of adding something like the nix darwin module to home-manager? 😄

I don't use yabai at the moment. Why don't you try adding it, though? 😊 It should basically be a drop-in solution and could be a good learning experience

@okkdev
Copy link

okkdev commented Mar 25, 2022

I don't use yabai at the moment. Why don't you try adding it, though? 😊 It should basically be a drop-in solution and could be a good learning experience

Hehe, I guess I'll have to try. Thanks for the quick reply! 😄

@bugeats
Copy link

bugeats commented Apr 5, 2022

Hey @cmacrae I'm a nix noob hoping that you can update the nix pkg to yabai 4.0.0.

Also +1 for home-manager support.

Repository owner locked and limited conversation to collaborators Apr 21, 2022
@koekeishiya koekeishiya converted this issue into discussion #1244 Apr 21, 2022

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
documentation Documentation
Projects
None yet
Development

No branches or pull requests

7 participants