From 240f1614d816dc504a6684a7d73618322d589f5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9ophane=20Hufschmitt?= Date: Mon, 11 Apr 2022 10:20:37 +0200 Subject: [PATCH] Add a proper nix option for the external GC --- src/libstore/gc.cc | 5 +++-- src/libstore/globals.hh | 7 +++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/libstore/gc.cc b/src/libstore/gc.cc index 104405d6e..98a7866a1 100644 --- a/src/libstore/gc.cc +++ b/src/libstore/gc.cc @@ -269,8 +269,9 @@ void LocalStore::findRootsNoTemp(Roots & roots, bool censor) throw SysError("cannot create Unix domain socket"); closeOnExec(fd.get()); - // FIXME: Don’t hardcode - string socketPath = getEnv("NIX_GC_SOCKET_PATH").value_or("/nix/var/nix/gc-socket/socket"); + std::string socketPath = settings.gcSocketPath.get() != "auto" + ? settings.gcSocketPath.get() + : stateDir.get() + gcSocketPath; struct sockaddr_un addr; addr.sun_family = AF_UNIX; diff --git a/src/libstore/globals.hh b/src/libstore/globals.hh index feb6899cd..d8db8be76 100644 --- a/src/libstore/globals.hh +++ b/src/libstore/globals.hh @@ -94,6 +94,13 @@ public: Setting storeUri{this, getEnv("NIX_REMOTE").value_or("auto"), "store", "The default Nix store to use."}; + Setting gcSocketPath { + this, + getEnv("NIX_GC_SOCKET_PATH").value_or("auto"), + "gc-socket-path", + "Path to the socket used to communicate with an external GC." + }; + Setting keepFailed{this, false, "keep-failed", "Whether to keep temporary directories of failed builds."};