Commit 96a2aea

Martin Häcker  ·  2026-07-08 16:28:29 -0400 EDT
parent 6fabec0
Fix darwin build (#190)

This modifies the build so the flake builds correctly on darwin.

`nix flake show` still creates an IFD in the zig2nix flake, but that was
a problem before and could be solved by setting pname and version in the
package - so nothing that got worse with this patch.
1 files changed,  +25, -6
+25, -6
......@@ -10,7 +10,7 @@
1010 let
1111 flake-utils = zig2nix.inputs.flake-utils;
1212 in
13- (flake-utils.lib.eachSystem [ "x86_64-linux" "aarch64-linux" ] (
13+ (flake-utils.lib.eachSystem [ "x86_64-linux" "aarch64-linux" "aarch64-darwin" "x86_64-darwin" ] (
1414 system:
1515 let
1616 env = zig2nix.outputs.zig-env.${system} {
......@@ -20,11 +20,30 @@
2020 with builtins;
2121 with env.pkgs.lib;
2222 let
23- zmx-package = env.package {
24- src = cleanSource ./.;
25- zigBuildFlags = [ "-Doptimize=ReleaseSafe" ];
26- zigPreferMusl = true;
27- };
23+ isDarwin = env.pkgs.stdenv.hostPlatform.isDarwin;
24+ sdkRoot = env.pkgs.apple-sdk.sdkroot;
25+ xcrunWrapper = env.pkgs.writeShellScriptBin "xcrun" ''
26+ echo "${sdkRoot}"
27+ '';
28+ xcodeselectWrapper = env.pkgs.writeShellScriptBin "xcode-select" ''
29+ echo "${sdkRoot}"
30+ '';
31+
32+ zmx-package = env.package (
33+ {
34+ src = cleanSource ./.;
35+ zigBuildFlags = [ "-Doptimize=ReleaseSafe" ];
36+ zigPreferMusl = !isDarwin;
37+ }
38+ // optionalAttrs isDarwin {
39+ glibc = null;
40+ musl = null;
41+ nativeBuildInputs = [
42+ xcrunWrapper
43+ xcodeselectWrapper
44+ ];
45+ }
46+ );
2847 in
2948 {
3049 packages = {