1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-28 05:00:58 +01:00

Merge pull request #14659 from vinayakankugoyal/path

Use std::filesystem::path in libflake.
This commit is contained in:
John Ericson 2025-11-27 00:07:58 +00:00 committed by GitHub
commit d3aa04561f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 14 additions and 14 deletions

View file

@ -31,9 +31,9 @@ namespace nix::flake {
// setting name -> setting value -> allow or ignore.
typedef std::map<std::string, std::map<std::string, bool>> TrustedList;
Path trustedListPath()
std::filesystem::path trustedListPath()
{
return getDataDir() + "/trusted-settings.json";
return getDataDir() / "trusted-settings.json";
}
static TrustedList readTrustedList()
@ -48,7 +48,7 @@ static TrustedList readTrustedList()
static void writeTrustedList(const TrustedList & trustedList)
{
auto path = trustedListPath();
createDirs(dirOf(path));
createDirs(path.parent_path());
writeFile(path, nlohmann::json(trustedList).dump());
}

View file

@ -74,7 +74,7 @@ FlakeRef::resolve(const fetchers::Settings & fetchSettings, Store & store, fetch
FlakeRef parseFlakeRef(
const fetchers::Settings & fetchSettings,
const std::string & url,
const std::optional<Path> & baseDir,
const std::optional<std::filesystem::path> & baseDir,
bool allowMissing,
bool isFlake,
bool preserveRelativePaths)
@ -101,7 +101,7 @@ fromParsedURL(const fetchers::Settings & fetchSettings, ParsedURL && parsedURL,
std::pair<FlakeRef, std::string> parsePathFlakeRefWithFragment(
const fetchers::Settings & fetchSettings,
const std::string & url,
const std::optional<Path> & baseDir,
const std::optional<std::filesystem::path> & baseDir,
bool allowMissing,
bool isFlake,
bool preserveRelativePaths)
@ -121,7 +121,7 @@ std::pair<FlakeRef, std::string> parsePathFlakeRefWithFragment(
to 'baseDir'). If so, search upward to the root of the
repo (i.e. the directory containing .git). */
path = absPath(path, baseDir, true);
path = absPath(path, baseDir->string(), true);
if (isFlake) {
@ -243,7 +243,7 @@ parseFlakeIdRef(const fetchers::Settings & fetchSettings, const std::string & ur
std::optional<std::pair<FlakeRef, std::string>> parseURLFlakeRef(
const fetchers::Settings & fetchSettings,
const std::string & url,
const std::optional<Path> & baseDir,
const std::optional<std::filesystem::path> & baseDir,
bool isFlake)
{
try {
@ -252,7 +252,7 @@ std::optional<std::pair<FlakeRef, std::string>> parseURLFlakeRef(
/* Here we know that the path must not contain encoded '/' or NUL bytes. */
auto path = renderUrlPathEnsureLegal(parsed.path);
if (!isAbsolute(path))
parsed.path = splitString<std::vector<std::string>>(absPath(path, *baseDir), "/");
parsed.path = splitString<std::vector<std::string>>(absPath(path, baseDir->string()), "/");
}
return fromParsedURL(fetchSettings, std::move(parsed), isFlake);
} catch (BadURL &) {
@ -263,7 +263,7 @@ std::optional<std::pair<FlakeRef, std::string>> parseURLFlakeRef(
std::pair<FlakeRef, std::string> parseFlakeRefWithFragment(
const fetchers::Settings & fetchSettings,
const std::string & url,
const std::optional<Path> & baseDir,
const std::optional<std::filesystem::path> & baseDir,
bool allowMissing,
bool isFlake,
bool preserveRelativePaths)
@ -347,7 +347,7 @@ FlakeRef FlakeRef::canonicalize() const
std::tuple<FlakeRef, std::string, ExtendedOutputsSpec> parseFlakeRefWithFragmentAndExtendedOutputsSpec(
const fetchers::Settings & fetchSettings,
const std::string & url,
const std::optional<Path> & baseDir,
const std::optional<std::filesystem::path> & baseDir,
bool allowMissing,
bool isFlake)
{

View file

@ -200,7 +200,7 @@ struct LockFlags
/**
* The path to a lock file to write to instead of the `flake.lock` file in the top-level flake
*/
std::optional<Path> outputLockFilePath;
std::optional<std::filesystem::path> outputLockFilePath;
/**
* Flake inputs to be overridden.

View file

@ -95,7 +95,7 @@ std::ostream & operator<<(std::ostream & str, const FlakeRef & flakeRef);
FlakeRef parseFlakeRef(
const fetchers::Settings & fetchSettings,
const std::string & url,
const std::optional<Path> & baseDir = {},
const std::optional<std::filesystem::path> & baseDir = {},
bool allowMissing = false,
bool isFlake = true,
bool preserveRelativePaths = false);
@ -106,7 +106,7 @@ FlakeRef parseFlakeRef(
std::pair<FlakeRef, std::string> parseFlakeRefWithFragment(
const fetchers::Settings & fetchSettings,
const std::string & url,
const std::optional<Path> & baseDir = {},
const std::optional<std::filesystem::path> & baseDir = {},
bool allowMissing = false,
bool isFlake = true,
bool preserveRelativePaths = false);
@ -117,7 +117,7 @@ std::pair<FlakeRef, std::string> parseFlakeRefWithFragment(
std::tuple<FlakeRef, std::string, ExtendedOutputsSpec> parseFlakeRefWithFragmentAndExtendedOutputsSpec(
const fetchers::Settings & fetchSettings,
const std::string & url,
const std::optional<Path> & baseDir = {},
const std::optional<std::filesystem::path> & baseDir = {},
bool allowMissing = false,
bool isFlake = true);