Skip to content

cli: continue converting Path to std::filesystem::path in CLI commands#15312

Merged
Ericson2314 merged 2 commits intoNixOS:masterfrom
obsidiansystems:convert-more-end-exes
Feb 24, 2026
Merged

cli: continue converting Path to std::filesystem::path in CLI commands#15312
Ericson2314 merged 2 commits intoNixOS:masterfrom
obsidiansystems:convert-more-end-exes

Conversation

@amaanq
Copy link
Member

@amaanq amaanq commented Feb 21, 2026

Motivation

This follows the previous commit 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 defers the std::filesystem::absolute(script.parent_path()) call in nix-build into the branch that actually needs it, since std::filesystem::absolute("") throws where the old absPath("") silently returned cwd.

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.

Context


Add 👍 to pull requests you find important.

The Nix maintainer team uses a GitHub project board to schedule and track reviews.

@github-actions github-actions bot added new-cli Relating to the "nix" command fetching Networking with the outside (non-Nix) world, input locking labels Feb 21, 2026
@amaanq amaanq changed the title cli: continue converting Path to std::filesystem::path in CLI commands cli: continue converting Path to std::filesystem::path in CLI commands Feb 21, 2026
@amaanq amaanq force-pushed the convert-more-end-exes branch from 408f83d to e766b78 Compare February 21, 2026 06:18
@Ericson2314 Ericson2314 force-pushed the convert-more-end-exes branch 2 times, most recently from 0a76d3f to 347ffc4 Compare February 23, 2026 17:28
@github-actions github-actions bot added store Issues and pull requests concerning the Nix store repl The Read Eval Print Loop, "nix repl" command and debugger labels Feb 23, 2026
@Ericson2314 Ericson2314 force-pushed the convert-more-end-exes branch from 347ffc4 to bbf20e4 Compare February 23, 2026 18:42
Ericson2314 and others added 2 commits February 23, 2026 15:41
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>
@Ericson2314 Ericson2314 force-pushed the convert-more-end-exes branch from bbf20e4 to a5a2562 Compare February 23, 2026 20:47
@Ericson2314
Copy link
Member

I added another commit before the main one

Replace renderUrlPathEnsureLegal with urlPathToPath

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.

This cleaned things up a bit before the big std::filesystem::path and runProgram args push, so that itself didn't have such a big Mercurial fetching diff.

@Ericson2314 Ericson2314 added this pull request to the merge queue Feb 24, 2026
Merged via the queue into NixOS:master with commit 003b644 Feb 24, 2026
14 checks passed
@Ericson2314 Ericson2314 deleted the convert-more-end-exes branch February 24, 2026 18:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fetching Networking with the outside (non-Nix) world, input locking new-cli Relating to the "nix" command repl The Read Eval Print Loop, "nix repl" command and debugger store Issues and pull requests concerning the Nix store

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants