!lheuhImcToQZYTQTuI:nixos.org

Nix on macOS

1174 Members
“There are still many issues with the Darwin platform but most of it is quite usable.” — http://yves.gnu-darwin.org190 Servers

Load older messages


SenderMessageTime
22 Dec 2025
@wshtk:matrix.orgwshtkHello all. I'm at a loss. Just upgraded to Tahoe the other day... have been running nix-darwin for three or four years on this computer, I rebooted today and suddenly everything was gone, like nix never existed. After hours of troubleshooting, completely reinstalling nix and rebuilding, I'm to the point that it seems that every time I reboot my symlink /run/current-system/ dissapears... rebuild the system or just replace the link, all is fine, reboot /run/current-system gone again. Any ideas what's wiping it?14:22:22
@ihar.hrachyshka:matrix.orgIhar Hrachyshka

Qemu nixpkgs vm hangs on boot sometimes, with traceback in Console that suggests FD_SETSIZE overflow in g_poll. both aarch64 and x86_64 emulated VMs are affected. lsof shows qemu using ~1024+ fds then.

Sometimes the issue happens, sometimes not (so a workaround is rebooting the VM several times until it "settles" on a relatively low number of FDs, ~500-700).

qemu has its own "g_poll" implementation for platforms that support ppoll() that doesn't go through glib loop. AFAIU macos doesn't support it. (?)

is this a known issue? is there anything we could do about it?

15:09:23
@wshtk:matrix.orgwshtksolved: https://github.com/nix-darwin/nix-darwin/issues/114815:26:20
@reckenrode:matrix.orgRandy Eckenrode As far as I call tell from the man pages, which admittedly kind of suck, all ppoll does is also let you wait on signals. As far as I can tell, g_poll does not let you do that. What is ppoll also doing in this case that one couldn’t do manually with poll? 15:31:30
@ihar.hrachyshka:matrix.orgIhar Hrachyshkaqemu g_poll implementation: https://github.com/qemu/qemu/blob/bb7fc1543fa45bebe7eded8115f25441a9fee76e/util/qemu-timer.c#L323-L34715:33:37
@ihar.hrachyshka:matrix.orgIhar Hrachyshka

in glib, there's this in meson

if host_system in ['windows', 'darwin']
  # Poll doesn't work on devices on Windows, and macOS's poll() implementation is known to be broken
  glib_conf.set('BROKEN_POLL', true)
endif

15:34:28
@reckenrode:matrix.orgRandy EckenrodeI wonder what they mean by “broken”.15:35:04
@reckenrode:matrix.orgRandy EckenrodeSometimes “broken” means “conforms to POSIX but doesn’t do what GNU does”.15:35:48
@ihar.hrachyshka:matrix.orgIhar Hrachyshka
/* The poll() emulation on OS/X doesn't handle fds=NULL, nfds=0,
 * so we prefer our own poll emulation.

15:35:50
@ihar.hrachyshka:matrix.orgIhar Hrachyshkathe MR that mentions tap networking broken? https://gitlab.gnome.org/GNOME/glib/-/merge_requests/257115:39:46
@ihar.hrachyshka:matrix.orgIhar Hrachyshkathere's a "check" they use to detect a "broken" poll here: https://gitlab.gnome.org/GNOME/glib/-/commit/caecf2dda082e9c46c4157cdc10763deb8dcfc27 but afaiu it is no longer needed and just forced on darwin. wonder if the check would pass now...15:40:56
@ihar.hrachyshka:matrix.orgIhar Hrachyshka* there's a "check" they use to detect a "broken" poll here: https://gitlab.gnome.org/GNOME/glib/-/commit/caecf2dda082e9c46c4157cdc10763deb8dcfc27 but afaiu it is no longer used and just forced on darwin. wonder if the check would pass now...15:41:04
@reckenrode:matrix.orgRandy Eckenrode According to POSIX, fds is an array. My understanding is that NULL is not a valid value for an array in C. 15:41:55
@ihar.hrachyshka:matrix.orgIhar Hrachyshkathe check compiled with xcode clang returns 115:42:22
@reckenrode:matrix.orgRandy Eckenrodehttps://pubs.opengroup.org/onlinepubs/9799919799/functions/poll.html15:42:38
@reckenrode:matrix.orgRandy Eckenrode ppoll is apparently part of POSIX now. No idea if or when Apple will add it. 15:43:07
@ihar.hrachyshka:matrix.orgIhar Hrachyshkathey could at least maybe conditionalize it. like if it's null and the user needs some non-standard behavior, go through select. otherwise... I think main loop for qemu doesn't pass nulls there.15:43:45
@ihar.hrachyshka:matrix.orgIhar Hrachyshkait's 2024 posix so rather new15:43:59
@reckenrode:matrix.orgRandy EckenrodeYeah. Apple is adding newer stuff, but they still only go for UNIX03 when they certify.15:44:53
@reckenrode:matrix.orgRandy EckenrodeSo no guarantee, particularly if they have alternative APIs already.15:45:24
@reckenrode:matrix.orgRandy EckenrodeDoes that means it works now?15:46:11
@ihar.hrachyshka:matrix.orgIhar Hrachyshka exit(1); /* Does not work for devices -- fail */ 15:46:34
@reckenrode:matrix.orgRandy EckenrodeThat code is almost twenty years old. It wouldn’t be the first time Glib makes an assumption that doesn’t apply on modern Darwin.15:46:48
@reckenrode:matrix.orgRandy Eckenrode What is the expected semantics when the user provides NULL fds and nfds 0? 15:47:44
@reckenrode:matrix.orgRandy Eckenrode * What are the expected semantics when the user provides NULL fds and nfds 0? 15:47:57
@reckenrode:matrix.orgRandy EckenrodeIs it equivalent to passing an empty array?15:48:53
@reckenrode:matrix.orgRandy Eckenrode macOS supports pselect but not ppoll? 15:51:13
@reckenrode:matrix.orgRandy Eckenrode Let’s look at the implementation. The signature takes a pointer, so NULL should be valid. 15:52:54
@ihar.hrachyshka:matrix.orgIhar Hrachyshkaone could probably implement g_poll conditioning to default to poll but fall back to select if a) any device fds passed or b) fds is null. then for most calls we would use poll.15:53:06
@ihar.hrachyshka:matrix.orgIhar Hrachyshka

that's on nixos

(ins)[nix-shell:/tmp]$ ./a.out
poll() returned: 0

(ins)[nix-shell:/tmp]$ cat test.c
#include <stdio.h>
#include <poll.h>
#include <errno.h>
#include <string.h>

int main() {
    int result = poll(NULL, 0, 1000);

    printf("poll() returned: %d\n", result);

    if (result == -1) {
        printf("Error: %s\n", strerror(errno));
    }

    return 0;
}


(ins)[nix-shell:/tmp]$ clang ./test.c

(ins)[nix-shell:/tmp]$ ./a.out
poll() returned: 0
15:53:15

Show newer messages


Back to Room ListRoom Version: 6