From 7cc7fdacbe166878079d583b5c337967742a6276 Mon Sep 17 00:00:00 2001 From: Puck Meerburg Date: Thu, 2 Jan 2020 17:20:57 +0000 Subject: fix(3p/nix): passAsFile: hash the attribute name instead of numbering sequentially This makes the paths consistent without relying on ordering. Co-authored-by: edef (cherry picked from commit 515c0a263e137a00e82f7d981284dbe54db23247) --- third_party/nix/src/libstore/build.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'third_party') diff --git a/third_party/nix/src/libstore/build.cc b/third_party/nix/src/libstore/build.cc index 0b4bce1820..e7a9ea45e6 100644 --- a/third_party/nix/src/libstore/build.cc +++ b/third_party/nix/src/libstore/build.cc @@ -2485,12 +2485,12 @@ void DerivationGoal::initTmpDir() { if (!parsedDrv->getStructuredAttrs()) { std::set passAsFile = absl::StrSplit(get(drv->env, "passAsFile"), absl::ByAnyChar(" \t\n\r")); - int fileNr = 0; for (auto& i : drv->env) { if (passAsFile.find(i.first) == passAsFile.end()) { env[i.first] = i.second; } else { - std::string fn = ".attr-" + std::to_string(fileNr++); + auto hash = hashString(htSHA256, i.first); + std::string fn = ".attr-" + hash.to_string(); Path p = tmpDir + "/" + fn; writeFile(p, rewriteStrings(i.second, inputRewrites)); chownToBuilder(p); -- cgit 1.4.1