2024-05-15 15:35:15 +00:00
|
|
|
{
|
|
|
|
lib,
|
|
|
|
stdenv,
|
|
|
|
overrideSDK,
|
|
|
|
fetchFromGitHub,
|
|
|
|
fetchzip,
|
|
|
|
installShellFiles,
|
|
|
|
testers,
|
|
|
|
writeShellScript,
|
|
|
|
common-updater-scripts,
|
|
|
|
curl,
|
|
|
|
darwin,
|
|
|
|
jq,
|
|
|
|
xcodebuild,
|
|
|
|
xxd,
|
|
|
|
yabai,
|
2022-10-30 15:09:59 +00:00
|
|
|
}:
|
2024-05-15 15:35:15 +00:00
|
|
|
let
|
|
|
|
inherit (darwin.apple_sdk_11_0.frameworks)
|
|
|
|
Carbon
|
|
|
|
Cocoa
|
|
|
|
ScriptingBridge
|
|
|
|
SkyLight
|
|
|
|
;
|
2020-05-03 17:38:23 +00:00
|
|
|
|
2024-05-15 15:35:15 +00:00
|
|
|
stdenv' = if stdenv.isDarwin then overrideSDK stdenv "11.0" else stdenv;
|
|
|
|
in
|
|
|
|
stdenv'.mkDerivation (finalAttrs: {
|
2020-05-03 17:38:23 +00:00
|
|
|
pname = "yabai";
|
2024-04-21 15:54:59 +00:00
|
|
|
version = "7.1.0";
|
|
|
|
|
2024-05-15 15:35:15 +00:00
|
|
|
src =
|
|
|
|
finalAttrs.passthru.sources.${stdenv.hostPlatform.system}
|
|
|
|
or (throw "Unsupported system: ${stdenv.hostPlatform.system}");
|
2024-04-21 15:54:59 +00:00
|
|
|
|
|
|
|
env = {
|
|
|
|
# silence service.h error
|
|
|
|
NIX_CFLAGS_COMPILE = "-Wno-implicit-function-declaration";
|
|
|
|
};
|
|
|
|
|
2024-05-15 15:35:15 +00:00
|
|
|
nativeBuildInputs =
|
|
|
|
[ installShellFiles ]
|
|
|
|
++ lib.optionals stdenv.isx86_64 [
|
|
|
|
xcodebuild
|
|
|
|
xxd
|
|
|
|
];
|
2024-04-21 15:54:59 +00:00
|
|
|
|
2024-05-15 15:35:15 +00:00
|
|
|
buildInputs = lib.optionals stdenv.isx86_64 [
|
2024-04-21 15:54:59 +00:00
|
|
|
Carbon
|
|
|
|
Cocoa
|
|
|
|
ScriptingBridge
|
|
|
|
SkyLight
|
|
|
|
];
|
|
|
|
|
|
|
|
dontConfigure = true;
|
|
|
|
dontBuild = stdenv.isAarch64;
|
|
|
|
enableParallelBuilding = true;
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
runHook preInstall
|
|
|
|
|
|
|
|
mkdir -p $out/{bin,share/icons/hicolor/scalable/apps}
|
|
|
|
|
|
|
|
cp ./bin/yabai $out/bin/yabai
|
|
|
|
${lib.optionalString stdenv.isx86_64 "cp ./assets/icon/icon.svg $out/share/icons/hicolor/scalable/apps/yabai.svg"}
|
|
|
|
installManPage ./doc/yabai.1
|
|
|
|
|
|
|
|
runHook postInstall
|
|
|
|
'';
|
|
|
|
|
2024-05-15 15:35:15 +00:00
|
|
|
postPatch =
|
|
|
|
lib.optionalString stdenv.isx86_64 # bash
|
|
|
|
''
|
|
|
|
# aarch64 code is compiled on all targets, which causes our Apple SDK headers to error out.
|
|
|
|
# Since multilib doesn't work on darwin i dont know of a better way of handling this.
|
|
|
|
substituteInPlace makefile \
|
|
|
|
--replace "-arch arm64e" "" \
|
|
|
|
--replace "-arch arm64" "" \
|
|
|
|
--replace "clang" "${stdenv.cc.targetPrefix}clang"
|
|
|
|
|
|
|
|
# `NSScreen::safeAreaInsets` is only available on macOS 12.0 and above, which frameworks aren't packaged.
|
|
|
|
# When a lower OS version is detected upstream just returns 0, so we can hardcode that at compile time.
|
|
|
|
# https://github.com/koekeishiya/yabai/blob/v4.0.2/src/workspace.m#L109
|
|
|
|
substituteInPlace src/workspace.m \
|
|
|
|
--replace 'return screen.safeAreaInsets.top;' 'return 0;'
|
|
|
|
'';
|
2024-04-21 15:54:59 +00:00
|
|
|
|
|
|
|
passthru = {
|
|
|
|
tests.version = testers.testVersion {
|
|
|
|
package = yabai;
|
|
|
|
version = "yabai-v${finalAttrs.version}";
|
|
|
|
};
|
|
|
|
|
|
|
|
sources = {
|
|
|
|
# Unfortunately compiling yabai from source on aarch64-darwin is a bit complicated. We use the precompiled binary instead for now.
|
|
|
|
# See the comments on https://github.com/NixOS/nixpkgs/pull/188322 for more information.
|
|
|
|
"aarch64-darwin" = fetchzip {
|
|
|
|
url = "https://github.com/koekeishiya/yabai/releases/download/v${finalAttrs.version}/yabai-v${finalAttrs.version}.tar.gz";
|
|
|
|
hash = "sha256-88Sh2nizAQ0a0cnlnrkhb5x3VjHa372HhjHlmNjGdQ4=";
|
|
|
|
};
|
2024-05-15 15:35:15 +00:00
|
|
|
"x86_64-darwin" = fetchFromGitHub {
|
|
|
|
owner = "koekeishiya";
|
|
|
|
repo = "yabai";
|
|
|
|
rev = "v${finalAttrs.version}";
|
|
|
|
hash = "sha256-5iC1U6tyUYFLjOfnIxCrjCjj2deUZ/rvsJN4jlrr2Tc=";
|
|
|
|
};
|
2024-04-21 15:54:59 +00:00
|
|
|
};
|
2020-05-03 17:38:23 +00:00
|
|
|
|
2024-04-21 15:54:59 +00:00
|
|
|
updateScript = writeShellScript "update-yabai" ''
|
|
|
|
set -o errexit
|
2024-05-15 15:35:15 +00:00
|
|
|
export PATH="${
|
|
|
|
lib.makeBinPath [
|
|
|
|
curl
|
|
|
|
jq
|
|
|
|
common-updater-scripts
|
|
|
|
]
|
|
|
|
}"
|
2024-04-21 15:54:59 +00:00
|
|
|
NEW_VERSION=$(curl --silent https://api.github.com/repos/koekeishiya/yabai/releases/latest | jq '.tag_name | ltrimstr("v")' --raw-output)
|
|
|
|
if [[ "${finalAttrs.version}" = "$NEW_VERSION" ]]; then
|
|
|
|
echo "The new version same as the old version."
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
for platform in ${lib.escapeShellArgs finalAttrs.meta.platforms}; do
|
|
|
|
update-source-version "yabai" "0" "${lib.fakeHash}" --source-key="sources.$platform"
|
|
|
|
update-source-version "yabai" "$NEW_VERSION" --source-key="sources.$platform"
|
|
|
|
done
|
|
|
|
'';
|
2020-05-03 17:38:23 +00:00
|
|
|
};
|
|
|
|
|
2024-04-21 15:54:59 +00:00
|
|
|
meta = {
|
2022-10-30 15:09:59 +00:00
|
|
|
description = "A tiling window manager for macOS based on binary space partitioning";
|
|
|
|
longDescription = ''
|
|
|
|
yabai is a window management utility that is designed to work as an extension to the built-in
|
|
|
|
window manager of macOS. yabai allows you to control your windows, spaces and displays freely
|
|
|
|
using an intuitive command line interface and optionally set user-defined keyboard shortcuts
|
|
|
|
using skhd and other third-party software.
|
2020-05-03 17:38:23 +00:00
|
|
|
'';
|
|
|
|
homepage = "https://github.com/koekeishiya/yabai";
|
2024-04-21 15:54:59 +00:00
|
|
|
changelog = "https://github.com/koekeishiya/yabai/blob/v${finalAttrs.version}/CHANGELOG.md";
|
|
|
|
license = lib.licenses.mit;
|
|
|
|
platforms = builtins.attrNames finalAttrs.passthru.sources;
|
2023-10-09 19:29:22 +00:00
|
|
|
mainProgram = "yabai";
|
2024-04-21 15:54:59 +00:00
|
|
|
maintainers = with lib.maintainers; [
|
2022-10-30 15:09:59 +00:00
|
|
|
cmacrae
|
|
|
|
shardy
|
|
|
|
ivar
|
2023-10-09 19:29:22 +00:00
|
|
|
khaneliman
|
2022-10-30 15:09:59 +00:00
|
|
|
];
|
2024-05-15 15:35:15 +00:00
|
|
|
sourceProvenance =
|
|
|
|
with lib.sourceTypes;
|
|
|
|
lib.optionals stdenv.isx86_64 [ fromSource ] ++ lib.optionals stdenv.isAarch64 [ binaryNativeCode ];
|
2022-10-30 15:09:59 +00:00
|
|
|
};
|
2024-04-21 15:54:59 +00:00
|
|
|
})
|