edit: Allow opening paths that don't exist on disk in EDITOR - #15686
Merged
Merged
Conversation
xokdvium
commented
Apr 14, 2026
Comment on lines
+47
to
+57
| auto [args, tempFd, delTemp] = editorFor(file, line, /*readOnly=*/true); | ||
| auto program = args.front(); | ||
| args.pop_front(); | ||
|
|
||
| runProgram2( | ||
| RunOptions{ | ||
| .program = program, | ||
| .lookupPath = true, | ||
| .args = std::move(args), | ||
| .isInteractive = true, | ||
| }); |
Contributor
Author
There was a problem hiding this comment.
I had to change this up because we need the destructor of delTemp to run if we want to clean up the temp files. This seems a bit nicer overall too.
xokdvium
force-pushed
the
edit-temp-paths
branch
2 times, most recently
from
April 14, 2026 20:26
61b97ef to
391ca2c
Compare
Contributor
Author
|
This also has the nice effect of making this work too, which provides a really nice way of looking at the primitive operations that we bundle with in-memory files: |
xokdvium
force-pushed
the
edit-temp-paths
branch
2 times, most recently
from
April 14, 2026 20:53
48740f5 to
530c1b4
Compare
Since #14050 we now mount over the store paths in the rootFS accessor in the evaluator. This broke :e and nix edit on something like `:e "${outPath}/src/nix-manual/utils.nix"` when having the `github:nixos/nix` flake loaded in a `--pure-eval` repl. `nix edit` was also broken similarly with: `because it has no physical path`. For regular files, we can copy the outputs into a temporary read-only file and open that instead. For directories, we could open a directory listing in the editor, but I haven't implemented that here. Copying the whole directory tree seems a bit wasteful to me, so we can't truthfully mimic the old behavior of `:e` on directories (that editors usually allow the user to traverse when opened). This also implements some infrastructure for getting a writable file descriptor for the file that would get edited - I intend to use it for #15633.
xokdvium
force-pushed
the
edit-temp-paths
branch
from
April 14, 2026 20:57
530c1b4 to
58aeb06
Compare
Contributor
Author
|
Ok I think I fixed the mingw build now. |
Mic92
approved these changes
Apr 16, 2026
Merged
3 tasks done
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
Since #14050 we now mount over the store paths in the rootFS accessor in the evaluator. This broke :e and nix edit on something like
:e "${outPath}/src/nix-manual/utils.nix"when having thegithub:nixos/nixflake loaded in a--pure-evalrepl.nix editwas also broken similarly with:because it has no physical path.For regular files, we can copy the outputs into a temporary read-only file and open that instead. For directories, we could open a directory listing in the editor, but I haven't implemented that here. Copying the whole directory tree seems a bit wasteful to me, so we can't truthfully mimic the old behavior of
:eon directories (that editors usually allow the user to traverse when opened).This also implements some infrastructure for getting a writable file descriptor for the file that would get edited - I intend to use it for #15633.
Context
This got reported by @bryango in #14050 (comment).
Add 👍 to pull requests you find important.
The Nix maintainer team uses a GitHub project board to schedule and track reviews.