1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-24 22:11:15 +02:00

libstore: skip Spotlight processes when finding GC roots

Despite installations of Nix explicitly setting the `nobrowse` mount
option on the store, `mdworker` processes continue to run on newly
created files within it, which can result in spurious GC/path deletion
failures if the stars are aligned right.

IMO, the best way to fix this is to simply ignore any processes started
by the Spotlight user, so that's exactly what we do here.

Fixes: https://github.com/NixOS/nix/issues/6141
Change-Id: I6a6a636c70f3f443f07ba9280d5f1e04b2ed2985
This commit is contained in:
Winter 2025-04-19 02:26:26 -04:00 committed by Thomas Bereknyei
parent f683a555bf
commit c27b2a691e

View file

@ -414,8 +414,13 @@ void LocalStore::findRuntimeRoots(Roots & roots, bool censor)
if (getEnv("_NIX_TEST_NO_LSOF") != "1") {
try {
std::regex lsofRegex(R"(^n(/.*)$)");
// Despite installations of Nix explicitly setting the `nobrowse` mount
// option on the store, `mdworker` processes continue to run on newly
// created files within it, which can result in spurious GC/path deletion
// failures if the stars are aligned right.
auto lsofLines =
tokenizeString<std::vector<std::string>>(runProgram(LSOF, true, { "-n", "-w", "-F", "n" }), "\n");
tokenizeString<std::vector<std::string>>(runProgram(LSOF, true, { "-n", "-w", "-F", "n", "-u", "^89", "-g", "^89" }), "\n");
for (const auto & line : lsofLines) {
std::smatch match;
if (std::regex_match(line, match, lsofRegex))