7 common-updater-scripts,
15 stdenv.mkDerivation (finalAttrs: {
20 finalAttrs.passthru.sources.${stdenv.hostPlatform.system}
21 or (throw "Unsupported system: ${stdenv.hostPlatform.system}");
25 ++ lib.optionals stdenv.hostPlatform.isx86_64 [
29 buildInputs = lib.optionals stdenv.hostPlatform.isx86_64 [
34 dontBuild = stdenv.hostPlatform.isAarch64;
35 enableParallelBuilding = true;
40 mkdir -p $out/{bin,share/icons/hicolor/scalable/apps}
42 cp ./bin/yabai $out/bin/yabai
43 ${lib.optionalString stdenv.hostPlatform.isx86_64 "cp ./assets/icon/icon.svg $out/share/icons/hicolor/scalable/apps/yabai.svg"}
44 installManPage ./doc/yabai.1
50 lib.optionalString stdenv.hostPlatform.isx86_64 # bash
52 # aarch64 code is compiled on all targets, which causes our Apple SDK headers to error out.
53 # Since multilib doesn't work on darwin i dont know of a better way of handling this.
54 substituteInPlace makefile \
55 --replace-fail "-arch arm64e" "" \
56 --replace-fail "-arch arm64" ""
59 nativeInstallCheckInputs = [ versionCheckHook ];
60 versionCheckProgramArg = "--version";
61 doInstallCheck = true;
65 # Unfortunately compiling yabai from source on aarch64-darwin is a bit complicated. We use the precompiled binary instead for now.
66 # See the comments on https://github.com/NixOS/nixpkgs/pull/188322 for more information.
67 "aarch64-darwin" = fetchzip {
68 url = "https://github.com/koekeishiya/yabai/releases/download/v${finalAttrs.version}/yabai-v${finalAttrs.version}.tar.gz";
69 hash = "sha256-o+9Z3Kxo1ff1TZPmmE6ptdOSsruQzxZm59bdYvhRo3c=";
71 "x86_64-darwin" = fetchFromGitHub {
72 owner = "koekeishiya";
74 rev = "v${finalAttrs.version}";
75 hash = "sha256-6HBWJvjVWagtHrfjWaYSRcnQOuwTBVeVxo3wc+jSlyE=";
79 updateScript = writeShellScript "update-yabai" ''
85 common-updater-scripts
88 NEW_VERSION=$(curl --silent https://api.github.com/repos/koekeishiya/yabai/releases/latest | jq '.tag_name | ltrimstr("v")' --raw-output)
89 if [[ "${finalAttrs.version}" = "$NEW_VERSION" ]]; then
90 echo "The new version same as the old version."
93 for platform in ${lib.escapeShellArgs finalAttrs.meta.platforms}; do
94 update-source-version "yabai" "$NEW_VERSION" --ignore-same-version --source-key="sources.$platform"
100 description = "Tiling window manager for macOS based on binary space partitioning";
102 yabai is a window management utility that is designed to work as an extension to the built-in
103 window manager of macOS. yabai allows you to control your windows, spaces and displays freely
104 using an intuitive command line interface and optionally set user-defined keyboard shortcuts
105 using skhd and other third-party software.
107 homepage = "https://github.com/koekeishiya/yabai";
108 changelog = "https://github.com/koekeishiya/yabai/blob/v${finalAttrs.version}/CHANGELOG.md";
109 license = lib.licenses.mit;
110 platforms = builtins.attrNames finalAttrs.passthru.sources;
111 mainProgram = "yabai";
112 maintainers = with lib.maintainers; [
118 with lib.sourceTypes;
119 lib.optionals stdenv.hostPlatform.isx86_64 [ fromSource ]
120 ++ lib.optionals stdenv.hostPlatform.isAarch64 [ binaryNativeCode ];