Conversation
xokdvium
reviewed
Sep 23, 2026
| } | ||
| if (is_directory(localPath)) { | ||
| if (exists(localPath / ".git")) { | ||
| if (auto repoURL = getLocalRepoURL(localPath)) { |
Contributor
There was a problem hiding this comment.
One thing to be wary of is that previously we followed symlinks here, but no longer do. So a mere presence of .git in the repo is enough. I guess it's fine, .git pointing outside the repo is absolutely cursed and probably isn't allowed.
Member
Author
There was a problem hiding this comment.
Agreed, I'm not sure what use-cases there are for .git symlinks. worktrees use a file.
xokdvium
reviewed
Sep 23, 2026
| if (auto * localPathP = std::get_if<std::filesystem::path>(&actualUrl_)) { | ||
| auto & localPath = *localPathP; | ||
| auto unlocked = !input.getRef() && !input.getRev(); | ||
| auto isValidLocalRepo = pathExists(localPath / ".hg"); |
Contributor
There was a problem hiding this comment.
This doesn't need to change though?
xokdvium
reviewed
Sep 23, 2026
| Such a reference now resolves to `hg+file:`, so only tracked files are copied. | ||
| This needs the `hg` executable, as `hg+file:` inputs always did. | ||
|
|
||
| Input schemes, including ones from [`plugin-files`](@docroot@/command-ref/conf-file.md#conf-plugin-files), can claim a directory by implementing `InputScheme::localRepoURL()`. |
Contributor
There was a problem hiding this comment.
claim seems like the wrong word to describe the thing. It's more about hooking into cli path-like flakeref shorthands.
Member
Author
There was a problem hiding this comment.
agreed, switched it to "resolve path-like"
Motivation: add support for `jj` down the line. When loading a local flake directory, Nix would only detect `.git` repositories, and fallback on copying whole directories for other inputs. This change introduces `InputScheme::localRepoURL()`. Ports the Git and logics to its input. And adds the Mercurial support for it. After this change, I can write a jj plugin, and other SCMs can do the same thing. Assisted-by: Claude Code (claude-opus-5)
zimbatm
force-pushed
the
local-root-detection
branch
from
September 25, 2026 14:30
8e07e95 to
77aac4e
Compare
This branch has not been deployed
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
Add support for
jjflake inputs down the line.Context
When loading a local flake directory, Nix would only detect
.gitrepositories as a hard-coded logic, and fallback on copying whole directories for other inputs.This change introduces
InputScheme::localRepoURL(). Ports the Git and logic to its input. And adds the Mercurial support for it.After this change, I can write a jj plugin, and other SCMs can do the same thing.
Add 👍 to pull requests you find important.
The Nix maintainer team uses a GitHub project board to schedule and track reviews.