Open
Description
Is your feature request related to a problem?
-
- Nix currently resolves
git+file:relative/path
according to the process working directory instead of theflake.nix
base directory. This is unreliable. Evaluation should be invariant under the process working directory, or it would violate the ability to be used as a flake input, among other things. fetchTree
does not have a base directory argument (and no implicit argument either, because that'd also be bad)
- Nix currently resolves
- Therefore
fetchTree
does not have the information to resolve relative paths.
Solution for Flakes users
Users will be able to use a relative path reference since Nix 2.26 and they can enable submodules declaratively, planned for release in 2.27
{
# For Nix 2.27:
inputs.self.submodules = true;
# instead of: inputs.foo.url = "git+file://./my-submodule";
inputs.foo.url = ./my-submodule;
}
For Nix 2.26, instead of inputs.self.submodules
, use:
nix build .?submodules=true#my-package
Proposed solution (for fetchTree
)
- Disallow git relative path inputs in
fetchTree
- Either
- Resolve git relative path inputs in
call-flake.nix
(with a primop that does it? - unclear if that's future proof enough for reproducibility) - add a
baseDirectory
argument tofetchTree
- Resolve git relative path inputs in
Alternative solution
Forbid altogether. This blocks some users:
Additional context
- fetchers/git: make relative path absolute for local repo #12107
- Warn against the use of relative 'git+file:' flake inputs #12277
Add 👍 to issues you find important.