···887887 </listitem>
888888 <listitem>
889889 <para>
890890+ The <literal>bloat</literal> package has been updated from
891891+ unstable-2022-03-31 to unstable-2022-10-25, which brings a
892892+ breaking change. See
893893+ <link xlink:href="https://git.freesoftwareextremist.com/bloat/commit/?id=887ed241d64ba5db3fd3d87194fb5595e5ad7d73">this
894894+ upstream commit message</link> for details.
895895+ </para>
896896+ </listitem>
897897+ <listitem>
898898+ <para>
890899 The <literal>services.matrix-synapse</literal> systemd unit
891900 has been hardened.
892901 </para>
+2
nixos/doc/manual/release-notes/rl-2211.section.md
···283283 from `~/.local/share/polymc/polymc.cfg` to
284284 `~/.local/share/PrismLauncher/prismlauncher.cfg`.
285285286286+- The `bloat` package has been updated from unstable-2022-03-31 to unstable-2022-10-25, which brings a breaking change. See [this upstream commit message](https://git.freesoftwareextremist.com/bloat/commit/?id=887ed241d64ba5db3fd3d87194fb5595e5ad7d73) for details.
287287+286288- The `services.matrix-synapse` systemd unit has been hardened.
287289288290- The `services.grafana` options were converted to a [RFC 0042](https://github.com/NixOS/rfcs/blob/master/rfcs/0042-config-option.md) configuration.
···11-{ lib, stdenv, fetchFromGitHub, darwin, xxd }:
11+{ lib
22+, stdenv
33+, stdenvNoCC
44+, fetchFromGitHub
55+, fetchzip
66+, writeShellScript
77+, installShellFiles
88+, testers
99+, yabai
1010+, xxd
1111+, xcodebuild
1212+, Carbon
1313+, Cocoa
1414+, ScriptingBridge
1515+ # This needs to be from SDK 10.13 or higher, SLS APIs introduced in that version get used
1616+, SkyLight
1717+}:
21833-stdenv.mkDerivation rec {
1919+let
420 pname = "yabai";
55- version = "3.3.10";
2121+ version = "4.0.4";
62277- src = fetchFromGitHub {
88- owner = "koekeishiya";
99- repo = pname;
1010- rev = "v${version}";
1111- sha256 = "sha256-8O6//T894C32Pba3F2Z84Z6VWeCXlwml3xsXoIZGqL0=";
2323+ test-version = testers.testVersion {
2424+ package = yabai;
2525+ version = "yabai-v${version}";
1226 };
13271414- nativeBuildInputs = [ xxd ];
2828+ _meta = with lib; {
2929+ description = "A tiling window manager for macOS based on binary space partitioning";
3030+ longDescription = ''
3131+ yabai is a window management utility that is designed to work as an extension to the built-in
3232+ window manager of macOS. yabai allows you to control your windows, spaces and displays freely
3333+ using an intuitive command line interface and optionally set user-defined keyboard shortcuts
3434+ using skhd and other third-party software.
3535+ '';
3636+ homepage = "https://github.com/koekeishiya/yabai";
3737+ changelog = "https://github.com/koekeishiya/yabai/blob/v${version}/CHANGELOG.md";
3838+ license = licenses.mit;
3939+ platforms = platforms.darwin;
4040+ maintainers = with maintainers; [
4141+ cmacrae
4242+ shardy
4343+ ivar
4444+ ];
4545+ };
4646+in
4747+{
4848+ # Unfortunately compiling yabai from source on aarch64-darwin is a bit complicated. We use the precompiled binary instead for now.
4949+ # See the comments on https://github.com/NixOS/nixpkgs/pull/188322 for more information.
5050+ aarch64-darwin = stdenvNoCC.mkDerivation {
5151+ inherit pname version;
5252+5353+ src = fetchzip {
5454+ url = "https://github.com/koekeishiya/yabai/releases/download/v${version}/yabai-v${version}.tar.gz";
5555+ sha256 = "sha256-NS8tMUgovhWqc6WdkNI4wKee411i/e/OE++JVc86kFE=";
5656+ };
5757+5858+ nativeBuildInputs = [
5959+ installShellFiles
6060+ ];
6161+6262+ dontConfigure = true;
6363+ dontBuild = true;
6464+6565+ installPhase = ''
6666+ runHook preInstall
6767+6868+ mkdir -p $out
6969+ cp -r ./bin $out
7070+ installManPage ./doc/yabai.1
7171+7272+ runHook postInstall
7373+ '';
7474+7575+ passthru.tests.version = test-version;
7676+7777+ meta = _meta // {
7878+ sourceProvenance = with lib.sourceTypes; [
7979+ binaryNativeCode
8080+ ];
8181+ };
8282+ };
8383+8484+ x86_64-darwin = stdenv.mkDerivation rec {
8585+ inherit pname version;
8686+8787+ src = fetchFromGitHub {
8888+ owner = "koekeishiya";
8989+ repo = "yabai";
9090+ rev = "v${version}";
9191+ sha256 = "sha256-TeT+8UAV2jR60XvTs4phkp611Gi0nzLmQnezLA0xb44=";
9292+ };
9393+9494+ nativeBuildInputs = [
9595+ installShellFiles
9696+ xcodebuild
9797+ xxd
9898+ ];
9999+100100+ buildInputs = [
101101+ Carbon
102102+ Cocoa
103103+ ScriptingBridge
104104+ SkyLight
105105+ ];
106106+107107+ dontConfigure = true;
108108+ enableParallelBuilding = true;
109109+110110+ postPatch = ''
111111+ # aarch64 code is compiled on all targets, which causes our Apple SDK headers to error out.
112112+ # Since multilib doesnt work on darwin i dont know of a better way of handling this.
113113+ substituteInPlace makefile \
114114+ --replace "-arch arm64e" "" \
115115+ --replace "-arch arm64" "" \
116116+ --replace "clang" "${stdenv.cc.targetPrefix}clang"
117117+118118+ # `NSScreen::safeAreaInsets` is only available on macOS 12.0 and above, which frameworks arent packaged.
119119+ # When a lower OS version is detected upstream just returns 0, so we can hardcode that at compiletime.
120120+ # https://github.com/koekeishiya/yabai/blob/v4.0.2/src/workspace.m#L109
121121+ substituteInPlace src/workspace.m \
122122+ --replace 'return screen.safeAreaInsets.top;' 'return 0;'
123123+ '';
124124+125125+ installPhase = ''
126126+ runHook preInstall
127127+128128+ mkdir -p $out/{bin,share/icons/hicolor/scalable/apps}
129129+130130+ cp ./bin/yabai $out/bin/yabai
131131+ ln -s ${loadScriptingAddition} $out/bin/yabai-load-sa
132132+ cp ./assets/icon/icon.svg $out/share/icons/hicolor/scalable/apps/yabai.svg
133133+ installManPage ./doc/yabai.1
134134+135135+ runHook postInstall
136136+ '';
137137+138138+ # Defining this here exposes it as a passthru attribute, which is useful because it allows us to run `builtins.hashFile` on it in pure-eval mode.
139139+ # With that we can programatically generate an `/etc/sudoers.d` entry which disables the password requirement, so that a user-agent can run it at login.
140140+ loadScriptingAddition = writeShellScript "yabai-load-sa" ''
141141+ # For whatever reason the regular commands to load the scripting addition do not work, yabai will throw an error.
142142+ # The installation command mutably installs binaries to '/System', but then fails to start them. Manually running
143143+ # the bins as root does start the scripting addition, so this serves as a more user-friendly way to do that.
144144+145145+ set -euo pipefail
146146+147147+ if [[ "$EUID" != 0 ]]; then
148148+ echo "error: the scripting-addition loader must ran as root. try 'sudo $0'"
149149+ exit 1
150150+ fi
151151+152152+ loaderPath="/Library/ScriptingAdditions/yabai.osax/Contents/MacOS/mach_loader";
151531616- buildInputs = with darwin.apple_sdk.frameworks; [
1717- Carbon
1818- Cocoa
1919- ScriptingBridge
2020- SkyLight
2121- ];
154154+ if ! test -x "$loaderPath"; then
155155+ echo "could not locate the scripting-addition loader at '$loaderPath', installing it..."
156156+ echo "note: this may display an error"
221572323- installPhase = ''
2424- mkdir -p $out/bin
2525- mkdir -p $out/share/man/man1/
2626- cp ./bin/yabai $out/bin/yabai
2727- cp ./doc/yabai.1 $out/share/man/man1/yabai.1
2828- '';
158158+ eval "$(dirname "''${BASH_SOURCE[0]}")/yabai --install-sa" || true
159159+ sleep 1
160160+ fi
291613030- meta = with lib; {
3131- description = ''
3232- A tiling window manager for macOS based on binary space partitioning
162162+ echo "executing loader..."
163163+ eval "$loaderPath"
164164+ echo "scripting-addition started"
33165 '';
3434- homepage = "https://github.com/koekeishiya/yabai";
3535- platforms = platforms.darwin;
3636- maintainers = with maintainers; [ cmacrae shardy ];
3737- license = licenses.mit;
166166+167167+ passthru.tests.version = test-version;
168168+169169+ meta = _meta // {
170170+ longDescription = _meta.longDescription + ''
171171+ Note that due to a nix-only bug the scripting addition cannot be launched using the regular
172172+ procedure. Instead, you can use the provided `yabai-load-sa` script.
173173+ '';
174174+175175+ sourceProvenance = with lib.sourceTypes; [
176176+ fromSource
177177+ ];
178178+ };
38179 };
3939-}
180180+}.${stdenv.hostPlatform.system} or (throw "Unsupported platform ${stdenv.hostPlatform.system}")