1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-09 03:56:01 +01:00

Remove constructor from ChrootPath

I rather use designated initializers.
This commit is contained in:
John Ericson 2025-08-19 17:42:05 -04:00
parent bb600e1048
commit 4ab579b469
3 changed files with 9 additions and 15 deletions

View file

@ -135,7 +135,7 @@ struct ChrootDerivationBuilder : virtual DerivationBuilderImpl
for (auto & i : inputPaths) {
auto p = store.printStorePath(i);
pathsInChroot.insert_or_assign(p, store.toRealPath(p));
pathsInChroot.insert_or_assign(p, ChrootPath{.source = store.toRealPath(p)});
}
/* If we're repairing, checking or rebuilding part of a

View file

@ -69,7 +69,7 @@ struct DarwinDerivationBuilder : DerivationBuilderImpl
/* Add all our input paths to the chroot */
for (auto & i : inputPaths) {
auto p = store.printStorePath(i);
pathsInChroot.insert_or_assign(p, p);
pathsInChroot.insert_or_assign(p, ChrootPath{.source = p});
}
/* Violations will go to the syslog if you set this. Unfortunately the destination does not appear to be

View file

@ -112,13 +112,7 @@ protected:
struct ChrootPath
{
Path source;
bool optional;
ChrootPath(Path source = "", bool optional = false)
: source(source)
, optional(optional)
{
}
bool optional = false;
};
typedef std::map<Path, ChrootPath> PathsInChroot; // maps target path to source path
@ -886,14 +880,14 @@ DerivationBuilderImpl::PathsInChroot DerivationBuilderImpl::getPathsInSandbox()
}
size_t p = i.find('=');
if (p == std::string::npos)
pathsInChroot[i] = {i, optional};
pathsInChroot[i] = {.source = i, .optional = optional};
else
pathsInChroot[i.substr(0, p)] = {i.substr(p + 1), optional};
pathsInChroot[i.substr(0, p)] = {.source = i.substr(p + 1), .optional = optional};
}
if (hasPrefix(store.storeDir, tmpDirInSandbox())) {
throw Error("`sandbox-build-dir` must not contain the storeDir");
}
pathsInChroot[tmpDirInSandbox()] = tmpDir;
pathsInChroot[tmpDirInSandbox()] = {.source = tmpDir};
/* Add the closure of store paths to the chroot. */
StorePathSet closure;
@ -908,7 +902,7 @@ DerivationBuilderImpl::PathsInChroot DerivationBuilderImpl::getPathsInSandbox()
}
for (auto & i : closure) {
auto p = store.printStorePath(i);
pathsInChroot.insert_or_assign(p, p);
pathsInChroot.insert_or_assign(p, ChrootPath{.source = p});
}
PathSet allowedPaths = settings.allowedImpureHostPrefixes;
@ -964,9 +958,9 @@ DerivationBuilderImpl::PathsInChroot DerivationBuilderImpl::getPathsInSandbox()
} else {
auto p = line.find('=');
if (p == std::string::npos)
pathsInChroot[line] = line;
pathsInChroot[line] = {.source = line};
else
pathsInChroot[line.substr(0, p)] = line.substr(p + 1);
pathsInChroot[line.substr(0, p)] = {.source = line.substr(p + 1)};
}
}
}