cli: continue converting Path to std::filesystem::path in CLI commands#15312
Merged
Ericson2314 merged 2 commits intoNixOS:masterfrom Feb 24, 2026
Merged
cli: continue converting Path to std::filesystem::path in CLI commands#15312Ericson2314 merged 2 commits intoNixOS:masterfrom
Path to std::filesystem::path in CLI commands#15312Ericson2314 merged 2 commits intoNixOS:masterfrom
Conversation
Path to std::filesystem::path in CLI commands
Ericson2314
reviewed
Feb 21, 2026
Ericson2314
reviewed
Feb 21, 2026
Ericson2314
reviewed
Feb 21, 2026
Ericson2314
reviewed
Feb 21, 2026
Ericson2314
reviewed
Feb 21, 2026
Ericson2314
reviewed
Feb 21, 2026
Ericson2314
reviewed
Feb 21, 2026
Ericson2314
reviewed
Feb 21, 2026
408f83d to
e766b78
Compare
Ericson2314
reviewed
Feb 21, 2026
Ericson2314
reviewed
Feb 21, 2026
0a76d3f to
347ffc4
Compare
347ffc4 to
bbf20e4
Compare
We make `urlPathToPath` support relative paths for of Flakes. The mercurial fetching got a bit larger of a rework with this, by taking advantage of `std::variant`.
…mands Follows previous work by converting more string-based `Path` fields and locals to `std::filesystem::path` across the CLI layer: `MixOutLinkBase::outLink`, `CmdAddToStore::path`, `CmdBundle::outLink`, `CmdDevelop` redirects and shell, `nix-build`, `nix-channel`, `nix-env`, `nix-instantiate`, `nix-store`, and `upgrade-nix`. Also, change `runProgram` and friends to use `OsString` for argument lists, since those will be native strings. This allows us to avoid (potentially lossy) `std::filesystem::path` (wide chars on windows) -> `std::string` (narrow) -> `OsString` (i.e. `std::wstring` on Windows, wide again) round trips. For CLIs with no path arguments, there is a `toOsStrings` function for convenience, however. Progress on NixOS#9205 Co-authored-by: Amaan Qureshi <git@amaanq.com>
bbf20e4 to
a5a2562
Compare
Member
|
I added another commit before the main one
This cleaned things up a bit before the big |
Ericson2314
approved these changes
Feb 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
This follows the previous commit by converting more string-based
Pathfields and locals tostd::filesystem::pathacross the CLI layer:MixOutLinkBase::outLink,CmdAddToStore::path,CmdBundle::outLink,CmdDevelopredirects and shell,nix-build,nix-channel,nix-env,nix-instantiate,nix-store, andupgrade-nix. Also defers thestd::filesystem::absolute(script.parent_path())call innix-buildinto the branch that actually needs it, sincestd::filesystem::absolute("")throws where the oldabsPath("")silently returned cwd.Also, change
runProgramand friends to useOsStringfor argument lists, since those will be native strings. This allows us to avoid (potentially lossy)std::filesystem::path(wide chars on windows) ->std::string(narrow) ->OsString(i.e.std::wstringon Windows, wide again) round trips. For CLIs with no path arguments, there is atoOsStringsfunction for convenience, however.Context
std::filesystem::pathfrom XDG directory helpers #15311Add 👍 to pull requests you find important.
The Nix maintainer team uses a GitHub project board to schedule and track reviews.