Describe the bug
nix <cmd> --update-input ... fails when the following conditions come together:
- when called in a git worktree, i.e. when
.git is a file (pointing to the real repository) instead of a directory.
- when the worktree is clean
It reports the worktree as a shallow clone and that it needs a deep clone to update the inputs.
error: '/path/to/repo' is a shallow Git repository, but a non-shallow repository is needed
… while fetching the input 'git+file:///path/to/repo'
Steps To Reproduce
- Enter a git repo with a flake that has inputs.
- Create a worktree with
git worktree add ../workree branch
cd ../worktree
nix flake lock --update-input <input> or any other command that accepts the --update-input option
Expected behavior
Updates the input.
nix-env --version output
Workaround
- Run
nix <cmd> --update-input <input> path:., which forces nix to interpret the flake URL as a path and avoids the git+file:// codepath.
- Modify any tracked file (not necessarily
flake.lock) to make the tree dirty, also solves the issue.
Describe the bug
nix <cmd> --update-input ...fails when the following conditions come together:.gitis a file (pointing to the real repository) instead of a directory.It reports the worktree as a shallow clone and that it needs a deep clone to update the inputs.
Steps To Reproduce
git worktree add ../workree branchcd ../worktreenix flake lock --update-input <input>or any other command that accepts the--update-inputoptionExpected behavior
Updates the input.
nix-env --versionoutputWorkaround
nix <cmd> --update-input <input> path:., which forces nix to interpret the flake URL as a path and avoids thegit+file://codepath.flake.lock) to make the tree dirty, also solves the issue.