mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-11-16 05:41:16 +01:00
This commit addresses a bug that was introduced/made visible ina5cbb4d. The nixpkgs flake input (tracking nixpkgs-unstable) was updated from github:NixOS/nixpkgs/f6b44b2401525650256b977063dbcf830f762369 to github:NixOS/nixpkgs/0d59e0290eefe0f12512043842d7096c4070f30e and as a result the version of AppKit being linked against jumped from 2022.44.149 to 2487.50.124. Builds prior toa5cbb4dwere building against macOS 13 (Ventura) era frameworks due to the use of compatability stubs in nixpkgs, whereas the nixpkgs-unstable update ina5cbb4dnow links against the actual running system's framework versions (in this case, macOS 15). With github:NixOS/nixpkgs/f6b44b2401525650256b977063dbcf830f762369: ``` ❯ otool -L target/debug/komorebi | grep -E 'AppKit|Foundation|CoreFoundation|libSystem' /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 1775.118.101) /System/Library/Frameworks/AppKit.framework/Versions/C/AppKit (compatibility version 45.0.0, current version 2022.44.149) /System/Library/Frameworks/Foundation.framework/Versions/C/Foundation (compatibility version 300.0.0, current version 1775.118.101) /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1292.100.5) ``` With github:NixOS/nixpkgs/0d59e0290eefe0f12512043842d7096c4070f30e ``` ❯ otool -L target/debug/komorebi | grep -E 'AppKit|Foundation|CoreFoundation|libSystem' /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 2420.0.0) /System/Library/Frameworks/AppKit.framework/Versions/C/AppKit (compatibility version 45.0.0, current version 2487.50.124) /System/Library/Frameworks/Foundation.framework/Versions/C/Foundation (compatibility version 300.0.0, current version 2420.0.0) /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1345.100.2) ``` Somewhere between macOS 13 and macOS 15 Apple added stricter thread-safety assertions in the AppKit framework, which resulted in the calls to `NSWindow::close()` in border.rs to crash on an assertion failure ("transaction must be valid") ``` * thread #9, stop reason = EXC_BREAKPOINT (code=1, subcode=0x19e543cc0) frame #0: 0x000000019e543cc0 AppKit`-[NSWMWindowCoordinator performTransactionUsingBlock:] + 752 AppKit`-[NSWMWindowCoordinator performTransactionUsingBlock:]: -> 0x19e543cc0 <+752>: brk #0x1 0x19e543cc4 <+756>: adrp x0, 827 0x19e543cc8 <+760>: add x0, x0, #0x4ba ; "assertion failure: transaction must be valid" 0x19e543ccc <+764>: bl 0x19e6eb58c ; symbol stub for: _os_crash Target 0: (komorebi) stopped. (lldb) bt * thread #9, stop reason = EXC_BREAKPOINT (code=1, subcode=0x19e543cc0) * frame #0: 0x000000019e543cc0 AppKit`-[NSWMWindowCoordinator performTransactionUsingBlock:] + 752 frame #1: 0x000000019e372a00 AppKit`-[NSWindow(NSWMWindowManagement) window:didUpdateWithChangedProperties:] + 104 frame #2: 0x000000027a366720 WindowManagement`-[_WMWindow performUpdatesUsingBlock:] + 100 frame #3: 0x000000027a365714 WindowManagement`-[_WMWindow applyTags😷] + 712 frame #4: 0x000000027a365cf8 WindowManagement`-[_WMWindow setVisible:] + 84 frame #5: 0x000000019d91b064 AppKit`-[NSWindow _setVisible:] + 268 frame #6: 0x000000019da16df0 AppKit`-[NSWindow _doWindowWillBecomeHidden] + 88 frame #7: 0x000000019e3662e0 AppKit`-[NSWindow _reallyDoOrderWindowOutRelativeTo:] + 160 frame #8: 0x000000019e366794 AppKit`-[NSWindow _reallyDoOrderWindow:] + 80 frame #9: 0x000000019e3669e4 AppKit`-[NSWindow _doOrderWindow:] + 264 frame #10: 0x000000019e360c84 AppKit`-[NSWindow _finishClosingWindow] + 444 frame #11: 0x000000019daa6cc8 AppKit`-[NSWindow _close] + 380 frame #12: 0x0000000100c3380c komorebi`_$LT$$LP$$RP$$u20$as$u20$objc2..encode..EncodeArguments$GT$::__invoke::h1be54296556f108b(msg_send_fn=(libobjc.A.dylib`objc_msgSend), receiver=0x0000000132e09ea0, sel=Sel @ 0x0000000170b58e38, (null)=<unavailable>) at encode.rs:433:26 frame #13: 0x0000000100c30f84 komorebi`objc2::runtime::message_receiver::msg_send_primitive::send::h0de1c4d240a2223f(receiver=0x0000000132e09ea0, sel=Sel @ 0x0000000170b58e78, args=<unavailable>) at message_receiver.rs:172:18 frame #14: 0x0000000100c2e904 komorebi`objc2::runtime::message_receiver::MessageReceiver::send_message::h86c04ca17a2b6faf(self=0x0000000132e09ea0, sel=Sel @ 0x0000000170b58ed0, args=<unavailable>) at message_receiver.rs:432:38 frame #15: 0x0000000100b9b1bc komorebi`_$LT$MethodFamily$u20$as$u20$objc2..__macro_helpers..msg_send_retained..MsgSend$LT$Receiver$C$Return$GT$$GT$::send_message::h6cb30a52e558d44c(receiver=0x0000000132e09ea0, sel=Sel @ 0x0000000170b58f48, args=<unavailable>) at msg_send_retained.rs:35:28 frame #16: 0x0000000100ba14b8 komorebi`objc2_app_kit::generated::__NSWindow::NSWindow::close::h34bc4ef6fc286b23(self=0x0000000132e09ea0) at extern_methods.rs:266:14 frame #17: 0x00000001002b22f0 komorebi`komorebi::border_manager::border::Border::destroy::_$u7b$$u7b$closure$u7d$$u7d$::h61d54fa62ea0b107((null)=AutoreleasePool @ 0x0000000170b58fb8) at border.rs:161:35 ``` To fix this, this commit ensures that the call to `NSWindow::close()` is made on the main thread using `DispatchQueue::main().exec_sync()`.
204 lines
5.2 KiB
Nix
204 lines
5.2 KiB
Nix
{
|
|
description = "Build komorebi workspace";
|
|
|
|
inputs = {
|
|
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
|
flake-parts.url = "github:hercules-ci/flake-parts";
|
|
crane.url = "github:ipetkov/crane";
|
|
rust-overlay.url = "github:oxalica/rust-overlay";
|
|
treefmt-nix.url = "github:numtide/treefmt-nix";
|
|
};
|
|
|
|
outputs =
|
|
inputs@{
|
|
self,
|
|
nixpkgs,
|
|
flake-parts,
|
|
crane,
|
|
rust-overlay,
|
|
...
|
|
}:
|
|
let
|
|
mkKomorebiPackages =
|
|
{ pkgs }:
|
|
let
|
|
toolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
|
|
craneLib = (crane.mkLib pkgs).overrideToolchain toolchain;
|
|
version = "0.1.0";
|
|
|
|
src = pkgs.lib.cleanSourceWith {
|
|
src = ./.;
|
|
filter =
|
|
path: type:
|
|
(craneLib.filterCargoSources path type)
|
|
|| (pkgs.lib.hasInfix "/docs/" path)
|
|
|| (builtins.match ".*/docs/.*" path != null);
|
|
};
|
|
|
|
commonArgs = {
|
|
inherit src version;
|
|
strictDeps = true;
|
|
COMMIT_HASH = self.rev or (pkgs.lib.removeSuffix "-dirty" self.dirtyRev);
|
|
buildInputs = [
|
|
pkgs.gcc
|
|
pkgs.libiconv
|
|
];
|
|
};
|
|
|
|
cargoArtifacts = craneLib.buildDepsOnly commonArgs;
|
|
|
|
individualCrateArgs = commonArgs // {
|
|
inherit cargoArtifacts;
|
|
doCheck = false;
|
|
doDoc = false;
|
|
};
|
|
|
|
fullBuild = craneLib.buildPackage (
|
|
individualCrateArgs
|
|
// {
|
|
pname = "komorebi-workspace";
|
|
}
|
|
);
|
|
|
|
extractBinary =
|
|
binaryName:
|
|
pkgs.runCommand "komorebi-${binaryName}"
|
|
{
|
|
meta = fullBuild.meta // { };
|
|
}
|
|
''
|
|
mkdir -p $out/bin
|
|
cp ${fullBuild}/bin/${binaryName} $out/bin/
|
|
'';
|
|
in
|
|
{
|
|
inherit
|
|
craneLib
|
|
src
|
|
individualCrateArgs
|
|
fullBuild
|
|
;
|
|
komorebi = extractBinary "komorebi";
|
|
komorebic = extractBinary "komorebic";
|
|
komorebi-bar = extractBinary "komorebi-bar";
|
|
};
|
|
|
|
mkPkgs =
|
|
system:
|
|
import nixpkgs {
|
|
inherit system;
|
|
overlays = [ (import rust-overlay) ];
|
|
};
|
|
in
|
|
flake-parts.lib.mkFlake { inherit inputs; } {
|
|
systems = [
|
|
"aarch64-darwin"
|
|
"x86_64-darwin"
|
|
];
|
|
|
|
imports = [
|
|
inputs.treefmt-nix.flakeModule
|
|
];
|
|
|
|
perSystem =
|
|
{
|
|
system,
|
|
...
|
|
}:
|
|
let
|
|
pkgs = mkPkgs system;
|
|
build = mkKomorebiPackages { inherit pkgs; };
|
|
in
|
|
{
|
|
treefmt = {
|
|
projectRootFile = "flake.nix";
|
|
programs = {
|
|
deadnix.enable = true;
|
|
just.enable = true;
|
|
nixfmt.enable = true;
|
|
taplo.enable = true;
|
|
rustfmt = {
|
|
enable = true;
|
|
package = pkgs.rust-bin.nightly.latest.rustfmt;
|
|
};
|
|
};
|
|
};
|
|
|
|
checks = {
|
|
komorebi-workspace-clippy = build.craneLib.cargoClippy build.individualCrateArgs;
|
|
|
|
komorebi-workspace-fmt = build.craneLib.cargoFmt {
|
|
inherit (build) src;
|
|
};
|
|
|
|
komorebi-workspace-toml-fmt = build.craneLib.taploFmt {
|
|
src = pkgs.lib.sources.sourceFilesBySuffices build.src [ ".toml" ];
|
|
};
|
|
|
|
komorebi-workspace-deny = build.craneLib.cargoDeny {
|
|
inherit (build) src;
|
|
};
|
|
|
|
komorebi-workspace-nextest = build.craneLib.cargoNextest build.individualCrateArgs;
|
|
};
|
|
|
|
packages = {
|
|
inherit (build) komorebi komorebic komorebi-bar;
|
|
komorebi-full = build.fullBuild;
|
|
default = build.fullBuild;
|
|
};
|
|
|
|
apps = {
|
|
komorebi = {
|
|
type = "app";
|
|
program = "${build.komorebi}/bin/komorebi";
|
|
};
|
|
komorebic = {
|
|
type = "app";
|
|
program = "${build.komorebic}/bin/komorebic";
|
|
};
|
|
komorebi-bar = {
|
|
type = "app";
|
|
program = "${build.komorebi-bar}/bin/komorebi-bar";
|
|
};
|
|
default = {
|
|
type = "app";
|
|
program = "${build.fullBuild}/bin/komorebi";
|
|
};
|
|
};
|
|
|
|
devShells.default = import ./shell.nix {
|
|
inherit pkgs;
|
|
};
|
|
};
|
|
|
|
flake = {
|
|
overlays.default =
|
|
final: _:
|
|
let
|
|
pkgs = mkPkgs final.system;
|
|
build = mkKomorebiPackages {
|
|
inherit pkgs;
|
|
};
|
|
in
|
|
{
|
|
inherit (build) komorebi komorebic komorebi-bar;
|
|
komorebi-full = build.fullBuild;
|
|
};
|
|
|
|
overlays.komorebi =
|
|
final: _:
|
|
let
|
|
pkgs = mkPkgs final.system;
|
|
build = mkKomorebiPackages {
|
|
inherit pkgs;
|
|
};
|
|
in
|
|
{
|
|
inherit (build) komorebi komorebic komorebi-bar;
|
|
komorebi-full = build.fullBuild;
|
|
};
|
|
};
|
|
};
|
|
}
|