1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-25 14:51:16 +02:00

getSourcePath(): Return std::filesystem::path

This commit is contained in:
Eelco Dolstra 2025-01-17 13:17:58 +01:00
parent 9003343b53
commit f5548c17ed
7 changed files with 11 additions and 16 deletions

View file

@ -358,7 +358,7 @@ void Input::clone(const Path & destDir) const
scheme->clone(*this, destDir);
}
std::optional<Path> Input::getSourcePath() const
std::optional<std::filesystem::path> Input::getSourcePath() const
{
assert(scheme);
return scheme->getSourcePath(*this);
@ -461,7 +461,7 @@ Input InputScheme::applyOverrides(
return input;
}
std::optional<Path> InputScheme::getSourcePath(const Input & input) const
std::optional<std::filesystem::path> InputScheme::getSourcePath(const Input & input) const
{
return {};
}

View file

@ -164,7 +164,7 @@ public:
void clone(const Path & destDir) const;
std::optional<Path> getSourcePath() const;
std::optional<std::filesystem::path> getSourcePath() const;
/**
* Write a file to this input, for input types that support
@ -247,7 +247,7 @@ struct InputScheme
virtual void clone(const Input & input, const Path & destDir) const;
virtual std::optional<Path> getSourcePath(const Input & input) const;
virtual std::optional<std::filesystem::path> getSourcePath(const Input & input) const;
virtual void putFile(
const Input & input,

View file

@ -311,14 +311,9 @@ struct GitInputScheme : InputScheme
runProgram("git", true, args, {}, true);
}
// FIXME: return std::filesystem::path
std::optional<Path> getSourcePath(const Input & input) const override
std::optional<std::filesystem::path> getSourcePath(const Input & input) const override
{
auto repoInfo = getRepoInfo(input);
if (auto path = repoInfo.getPath())
return *path;
else
return std::nullopt;
return getRepoInfo(input).getPath();
}
void putFile(

View file

@ -126,7 +126,7 @@ struct MercurialInputScheme : InputScheme
return res;
}
std::optional<Path> getSourcePath(const Input & input) const override
std::optional<std::filesystem::path> getSourcePath(const Input & input) const override
{
auto url = parseURL(getStrAttr(input.attrs, "url"));
if (url.scheme == "file" && !input.getRef() && !input.getRev())

View file

@ -80,9 +80,9 @@ struct PathInputScheme : InputScheme
};
}
std::optional<Path> getSourcePath(const Input & input) const override
std::optional<std::filesystem::path> getSourcePath(const Input & input) const override
{
return getStrAttr(input.attrs, "path");
return getAbsPath(input);
}
void putFile(

View file

@ -781,7 +781,7 @@ LockedFlake lockFlake(
writeFile(*lockFlags.outputLockFilePath, newLockFileS);
} else {
auto relPath = (topRef.subdir == "" ? "" : topRef.subdir + "/") + "flake.lock";
auto outputLockFilePath = *sourcePath + "/" + relPath;
auto outputLockFilePath = *sourcePath / relPath;
bool lockFileExists = pathExists(outputLockFilePath);

View file

@ -696,7 +696,7 @@ struct CmdDevelop : Common, MixEnvironment
auto sourcePath = installableFlake->getLockedFlake()->flake.resolvedRef.input.getSourcePath();
if (sourcePath) {
if (chdir(sourcePath->c_str()) == -1) {
throw SysError("chdir to '%s' failed", *sourcePath);
throw SysError("chdir to %s failed", *sourcePath);
}
}
}