Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get rid of CanonPath::fromCwd #9948

Merged
merged 1 commit into from
Feb 12, 2024

Conversation

Ericson2314
Copy link
Member

Motivation

As discussed in the last Nix team meeting (2024-02-95), this method doesn't belong because CanonPath is a virtual/ideal absolute path format, not used in file systems beyond the native OS format for which a "current working directory" is defined.

Context

Progress towards #9205

Priorities and Process

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 repl The Read Eval Print Loop, "nix repl" command and debugger fetching Networking with the outside (non-Nix) world, input locking labels Feb 6, 2024
src/libcmd/editor-for.cc Outdated Show resolved Hide resolved
@@ -29,6 +29,6 @@ private:
std::map<std::string, std::string> autoArgs;
};

SourcePath lookupFileArg(EvalState & state, std::string_view s, CanonPath baseDir = CanonPath::fromCwd());
SourcePath lookupFileArg(EvalState & state, std::string_view s, const Path * baseDir = nullptr);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
SourcePath lookupFileArg(EvalState & state, std::string_view s, const Path * baseDir = nullptr);
SourcePath lookupFileArg(EvalState & state, std::string_view s, std::optional<Path> baseDir = std::nullopt);

seem cleaner, then we don't have to take addresses etc.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just did it that way because we didn't need a copy of a the base dir string, just a reference to it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also recall that std::optional<const Path &> doesn't work because C++ is silly.

src/libexpr/eval.cc Outdated Show resolved Hide resolved
src/libutil/posix-source-accessor.cc Outdated Show resolved Hide resolved
src/libutil/posix-source-accessor.hh Outdated Show resolved Hide resolved
@Ericson2314 Ericson2314 force-pushed the no-canon-path-from-cwd branch 3 times, most recently from 31865c3 to ff2315e Compare February 8, 2024 14:54
As discussed in the last Nix team meeting (2024-02-95), this method
doesn't belong because `CanonPath` is a virtual/ideal absolute path
format, not used in file systems beyond the native OS format for which a
"current working directory" is defined.

Progress towards NixOS#9205
@edolstra edolstra merged commit ec6ca6e into NixOS:master Feb 12, 2024
8 checks passed
@Ericson2314 Ericson2314 deleted the no-canon-path-from-cwd branch February 12, 2024 13:05
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
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants