1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-17 16:02:43 +01:00

Use the Nix wrappers to connect to the gc socket

These have a nice mechanism to bypass the absurdly low OSX socket path
length limit (needed for the CI to pass)
This commit is contained in:
Théophane Hufschmitt 2022-04-11 10:20:37 +02:00
parent 40e95a2e30
commit 5c6b9bc361

View file

@ -260,28 +260,17 @@ Roots LocalStore::findRoots(bool censor)
void LocalStore::findRootsNoTemp(Roots & roots, bool censor)
{
auto fd = AutoCloseFD(socket(PF_UNIX, SOCK_STREAM
#ifdef SOCK_CLOEXEC
| SOCK_CLOEXEC
#endif
, 0));
if (!fd)
throw SysError("cannot create Unix domain socket");
closeOnExec(fd.get());
auto fd = createUnixDomainSocket();
std::string socketPath = settings.gcSocketPath.get() != "auto"
? settings.gcSocketPath.get()
: stateDir.get() + gcSocketPath;
struct sockaddr_un addr;
addr.sun_family = AF_UNIX;
if (socketPath.size() + 1 >= sizeof(addr.sun_path))
throw Error("socket path '%1%' is too long", socketPath);
strcpy(addr.sun_path, socketPath.c_str());
if (::connect(fd.get(), (struct sockaddr *) &addr, sizeof(addr)) == -1)
try {
nix::connect(fd.get(), socketPath);
} catch (SysError & e) {
return findRootsNoTempNoExternalDaemon(roots, censor);
}
settings.requireExperimentalFeature(Xp::ExternalGCDaemon);