fetchers/git: make relative path absolute for local repo#12107
fetchers/git: make relative path absolute for local repo#12107mergify[bot] merged 4 commits intoNixOS:masterfrom
Conversation
aij
left a comment
There was a problem hiding this comment.
I gave it a quick try and it does work for me:
ivan@tobati:~/nixops/aij$ /nix/store/bn0djaymav6qa4zg5vaskzcaija5nq2p-nix-2.26.0pre20241227_9111645/bin/nix flake update
warning: updating lock file '/home/ivan/nixops/aij/flake.lock':
• Updated input 'unstable':
'git+file:unstable?rev=3f0036916daca9836ba2c3f236b0ae051949a0a8' (2024-12-21)
→ 'git+file:unstable?ref=refs/heads/ipmiutil&rev=174ae1b581ddd6d5a6c55684da392e0baf500b1e' (2024-12-27)
|
For the example in #9709, namely doesn't this result in a lock file that has the absolute path of the original Git repo in it? I.e. if I run |
@edolstra Actually, no! It still gets locked to the relative path and shows up in |
| cat > "$rootRepo"/flake.nix <<EOF | ||
| { | ||
| inputs.subRepo.url = "git+file:./submodule"; | ||
| outputs = { ... }: { }; | ||
| } | ||
| EOF | ||
| git -C "$rootRepo" add flake.nix | ||
| git -C "$rootRepo" commit -m "Add flake.nix" | ||
| ( | ||
| cd "$rootRepo" | ||
| # The submodule must be locked to the relative path, | ||
| # _not_ the absolute path: | ||
| [[ $(nix flake metadata --json | jq -r .locks.nodes.subRepo.locked.url) = "file:./submodule" ]] | ||
| ) |
There was a problem hiding this comment.
submodule does get locked to the relative path file:./submodule. I don't understand why but hey, it works!
|
Draft-ing and un-draft-ing to try to unlock the new CI... |
|
Rebased for GHA config update |
Relative, local git repo used to work (for submodules), but it fails after 3e0129c. This commit adds a test to prevent such failure in the future.
|
Rebased again, conflicts resolved, CI happy. |
|
Thanks! @mergify queue |
…on of NixOS/nix#9708 I got tired of manually running ``` /nix/store/bn0djaymav6qa4zg5vaskzcaija5nq2p-nix-2.26.0pre20241227_9111645/bin/nix flake update ``` for every update while waiting for the fix to make it upstreaam.
|
@mergify queue |
✅ The pull request has been merged automaticallyDetailsThe pull request has been merged automatically at 9c239d4 |
…2107 fetchers/git: make relative path absolute for local repo (backport #12107)
| // | ||
| // See: https://discourse.nixos.org/t/57783 and #9708 | ||
| // | ||
| repoInfo.url = repoInfo.isLocal ? std::filesystem::absolute(url.path).string() : url.to_string(); |
There was a problem hiding this comment.
I'm a bit baffled by this. As the comment notes, resolving relative to the cwd is wrong since it could be anything. So why are we doing this?
|
I fear that this PR enshrines some extremely undesirable semantics, namely that At the very least, we should print a warning that users should not rely on this behaviour. |
|
This was a calculated decision to merge. I believe an alternate result is not possible, and that the wrong behavior would only cause a direct failure ("mysteriously fail"). I've approved it as a workaround, not as a solution. I've written #12281 to clarify the situation and discuss / track the final solution. |
|
Yes, this is not the ideal behavior; it's a band-aid to fix the cryptic core-dumped assertion error as in #9708 (comment). Note that this PR was proposed and reviewed way before #12254. If the latter fix achieves the same purpose, Update: without 96bd9ba we would still land on an assertion error, so it would be better to proceed from #12277. |
…regression of NixOS/nix#9708" As of Nix 2.24.12, `nix flake update` works with relative paths again, though it warns it is not supported and will be changed in 2.27. See NixOS/nix#12281 This reverts commit 2798e3c.
Motivation
Closes #9708 (again).
This patch:
git+file:./${submodule}to continue working.Context
Flake URIs such as
git+file:./${submodule}used to work before 2.18, but broke in 2.19, was fixed later, and broke again recently since 3e0129c, resulting in a core-dumped assertion error in #9708 (comment).This PR suppresses the error and allows
git+file:./${submodule}to continue working. However, this fix is not ideal and should potentially be superseded by a better submodule implementation in the future. See:git+file:./${submodule}no longer works #9708A better fix is outlined by @roberth in https://discourse.nixos.org/t/57783, namely:
Add 👍 to pull requests you find important.
The Nix maintainer team uses a GitHub project board to schedule and track reviews.
Friendly pings: