diff options
| author | Fuwn <[email protected]> | 2026-01-20 18:09:24 -0800 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2026-01-20 18:26:19 -0800 |
| commit | 8a904e34154dec998aa64cc0666e84e1f1ee7b99 (patch) | |
| tree | eae1e1b64e131ab30df988a263019e3b18f14c91 | |
| parent | add README.md (diff) | |
| download | zigr-8a904e34154dec998aa64cc0666e84e1f1ee7b99.tar.xz zigr-8a904e34154dec998aa64cc0666e84e1f1ee7b99.zip | |
build: Add macOS support using Nix
| -rw-r--r-- | build.zig | 10 | ||||
| -rw-r--r-- | flake.lock | 59 | ||||
| -rw-r--r-- | flake.nix | 51 |
3 files changed, 120 insertions, 0 deletions
@@ -18,6 +18,16 @@ pub fn build(b: *std.Build) void { zigr_mod.linkSystemLibrary("opengl32", .{}); zigr_mod.linkSystemLibrary("gdi32", .{}); }, + .macos => { + if (std.process.getEnvVarOwned(b.graph.arena, "SDKROOT")) |sdkroot| { + zigr_mod.addFrameworkPath(std.Build.LazyPath{ + .cwd_relative = b.fmt("{s}/System/Library/Frameworks", .{sdkroot}), + }); + } else |_| {} + + zigr_mod.linkFramework("Cocoa", .{}); + zigr_mod.linkFramework("OpenGL", .{}); + }, else => { zigr_mod.linkSystemLibrary("X11", .{}); zigr_mod.linkSystemLibrary("GL", .{}); diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..53b4fd6 --- /dev/null +++ b/flake.lock @@ -0,0 +1,59 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1731533236, + "owner": "numtide", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1768564909, + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "e4bae1bd10c9c57b2cf517953ab70060a828ee6f", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..3b1af92 --- /dev/null +++ b/flake.nix @@ -0,0 +1,51 @@ +{ + description = "Zig bindings for TIGR"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + flake-utils.url = "github:numtide/flake-utils"; + }; + + outputs = + { + self, + nixpkgs, + flake-utils, + }: + flake-utils.lib.eachDefaultSystem ( + system: + let + pkgs = import nixpkgs { inherit system; }; + + linuxDeps = with pkgs; [ + xorg.libX11 + libGL + libGLU + ]; + + darwinDeps = with pkgs; [ + apple-sdk_15 + libiconv + ]; + in + { + devShells.default = pkgs.mkShell.override { stdenv = pkgs.stdenvNoCC; } { + packages = + [ + pkgs.zig + ] + ++ pkgs.lib.optionals pkgs.stdenv.isLinux ([ pkgs.pkg-config ] ++ linuxDeps) + ++ pkgs.lib.optionals pkgs.stdenv.isDarwin darwinDeps; + + env = pkgs.lib.optionalAttrs pkgs.stdenv.isDarwin { + SDKROOT = "${pkgs.apple-sdk_15.sdkroot}"; + }; + + shellHook = '' + echo "ZIGR development shell" + echo "Zig version: $(zig version)" + ''; + }; + } + ); +} |