mirror of
https://github.com/NixOS/nix
synced 2025-06-25 19:01:16 +02:00
getSourcePath(): Return std::filesystem::path
This commit is contained in:
parent
9003343b53
commit
f5548c17ed
7 changed files with 11 additions and 16 deletions
|
@ -358,7 +358,7 @@ void Input::clone(const Path & destDir) const
|
||||||
scheme->clone(*this, destDir);
|
scheme->clone(*this, destDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<Path> Input::getSourcePath() const
|
std::optional<std::filesystem::path> Input::getSourcePath() const
|
||||||
{
|
{
|
||||||
assert(scheme);
|
assert(scheme);
|
||||||
return scheme->getSourcePath(*this);
|
return scheme->getSourcePath(*this);
|
||||||
|
@ -461,7 +461,7 @@ Input InputScheme::applyOverrides(
|
||||||
return input;
|
return input;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<Path> InputScheme::getSourcePath(const Input & input) const
|
std::optional<std::filesystem::path> InputScheme::getSourcePath(const Input & input) const
|
||||||
{
|
{
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
|
@ -164,7 +164,7 @@ public:
|
||||||
|
|
||||||
void clone(const Path & destDir) const;
|
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
|
* 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 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(
|
virtual void putFile(
|
||||||
const Input & input,
|
const Input & input,
|
||||||
|
|
|
@ -311,14 +311,9 @@ struct GitInputScheme : InputScheme
|
||||||
runProgram("git", true, args, {}, true);
|
runProgram("git", true, args, {}, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: return std::filesystem::path
|
std::optional<std::filesystem::path> getSourcePath(const Input & input) const override
|
||||||
std::optional<Path> getSourcePath(const Input & input) const override
|
|
||||||
{
|
{
|
||||||
auto repoInfo = getRepoInfo(input);
|
return getRepoInfo(input).getPath();
|
||||||
if (auto path = repoInfo.getPath())
|
|
||||||
return *path;
|
|
||||||
else
|
|
||||||
return std::nullopt;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void putFile(
|
void putFile(
|
||||||
|
|
|
@ -126,7 +126,7 @@ struct MercurialInputScheme : InputScheme
|
||||||
return res;
|
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"));
|
auto url = parseURL(getStrAttr(input.attrs, "url"));
|
||||||
if (url.scheme == "file" && !input.getRef() && !input.getRev())
|
if (url.scheme == "file" && !input.getRef() && !input.getRev())
|
||||||
|
|
|
@ -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(
|
void putFile(
|
||||||
|
|
|
@ -781,7 +781,7 @@ LockedFlake lockFlake(
|
||||||
writeFile(*lockFlags.outputLockFilePath, newLockFileS);
|
writeFile(*lockFlags.outputLockFilePath, newLockFileS);
|
||||||
} else {
|
} else {
|
||||||
auto relPath = (topRef.subdir == "" ? "" : topRef.subdir + "/") + "flake.lock";
|
auto relPath = (topRef.subdir == "" ? "" : topRef.subdir + "/") + "flake.lock";
|
||||||
auto outputLockFilePath = *sourcePath + "/" + relPath;
|
auto outputLockFilePath = *sourcePath / relPath;
|
||||||
|
|
||||||
bool lockFileExists = pathExists(outputLockFilePath);
|
bool lockFileExists = pathExists(outputLockFilePath);
|
||||||
|
|
||||||
|
|
|
@ -696,7 +696,7 @@ struct CmdDevelop : Common, MixEnvironment
|
||||||
auto sourcePath = installableFlake->getLockedFlake()->flake.resolvedRef.input.getSourcePath();
|
auto sourcePath = installableFlake->getLockedFlake()->flake.resolvedRef.input.getSourcePath();
|
||||||
if (sourcePath) {
|
if (sourcePath) {
|
||||||
if (chdir(sourcePath->c_str()) == -1) {
|
if (chdir(sourcePath->c_str()) == -1) {
|
||||||
throw SysError("chdir to '%s' failed", *sourcePath);
|
throw SysError("chdir to %s failed", *sourcePath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue