Skip to content

Add package separation for nix-darwin users with a macOS Sdk installation present - #11667

Closed
haze wants to merge 2 commits into
ziglang:masterfrom
haze:haze/nix-darwin-fixes
Closed

Add package separation for nix-darwin users with a macOS Sdk installation present#11667
haze wants to merge 2 commits into
ziglang:masterfrom
haze:haze/nix-darwin-fixes

Conversation

@haze

@haze haze commented May 18, 2022

Copy link
Copy Markdown
Contributor

Add nix_include_dirs and nix_framework_dirs for nix-darwin users who have packages installed that aren't relative to an existing SDK root

(this makes it so zig can find and build against c libraries provided by a shell.nix)

lib_dirs: ArrayList([:0]u8),
framework_dirs: ArrayList([:0]u8),

nix_framework_dirs: ArrayList([:0]u8),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should figure out a way of satisfying nix-darwin without such special-casing like that.

@haze haze May 18, 2022

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All nix users will have this problem. It's just that Darwin users also have an sdk root, so Zig attempts to add the paths in relation to, which is incorrect. It's not special casing it's support.

@haze

haze commented May 18, 2022

Copy link
Copy Markdown
Contributor Author

repro:

test_time.c

#include <time.h>
#include <stdio.h>

int main() {
  struct timespec time;
  int status = clock_gettime(CLOCK_REALTIME, &time);
  printf("%ld\n", time.tv_sec);
}

shell.nix

{ pkgs ? import <nixpkgs> {}, pkgs_unstable ? import <nixpkgs-unstable> {}, }:
  pkgs.mkShell {
    nativeBuildInputs = [ 
      pkgs.llvmPackages_13.libclang
      pkgs.darwin.apple_sdk.MacOSX-SDK
    ];
}

(this gives you a library and also a clang to test against that doesn't have the sysroot baked in)

Comment thread src/main.zig Outdated
@haze
haze force-pushed the haze/nix-darwin-fixes branch 2 times, most recently from 88a4042 to ad186a0 Compare June 6, 2022 02:39
@haze
haze force-pushed the haze/nix-darwin-fixes branch from ad186a0 to ccb8f63 Compare June 21, 2022 04:57
@andrewrk
andrewrk force-pushed the haze/nix-darwin-fixes branch from ccb8f63 to 429b1b0 Compare December 12, 2022 02:47
@haze haze closed this Dec 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants