passAsFile: hash the attribute name instead of numbering sequentially
This makes the paths consistent without relying on ordering. Co-authored-by: edef <edef@edef.eu>
This commit is contained in:
parent
3469062e76
commit
515c0a263e
|
@ -2455,12 +2455,12 @@ void DerivationGoal::initTmpDir() {
|
|||
if (!parsedDrv->getStructuredAttrs()) {
|
||||
|
||||
StringSet passAsFile = tokenizeString<StringSet>(get(drv->env, "passAsFile").value_or(""));
|
||||
int fileNr = 0;
|
||||
for (auto & i : drv->env) {
|
||||
if (passAsFile.find(i.first) == passAsFile.end()) {
|
||||
env[i.first] = i.second;
|
||||
} else {
|
||||
string fn = ".attr-" + std::to_string(fileNr++);
|
||||
auto hash = hashString(htSHA256, i.first);
|
||||
string fn = ".attr-" + hash.to_string();
|
||||
Path p = tmpDir + "/" + fn;
|
||||
writeFile(p, i.second);
|
||||
chownToBuilder(p);
|
||||
|
|
Loading…
Reference in a new issue