You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
nix help flake explains that path:<path> flakes are equivalent to git+file://<path> flakes with an inferred dir parameter if the path or any of its parents is a git repository. This does not appear to be true in general. Paths without the path: prefix given to nix commands as arguments do infer the git+file type, but arguments with an explicit path: don't, nor do paths specified in the nix registry or given to builtins.getFlake.
So there's two issues here:
The documentation says path:<path> and git+file://<path> are roughly equivalent, except they're not as the path: flake copies the entire referenced source directory whereas git+file: copies the git worktree. This means the former will include untracked files that the latter skips (including the .git directory itself), the metadata is different, and parameters like ?rev= don't work (see builtins.getFlake doesn’t use git+file protocol if available #5670).
The documentation says that specifying just <path> by itself is the same as path:<path> (in that the specified URL form here is [path:]<path>(?<params>)?). This is true for builtins.getFlake and for the registry (and presumably for flake inputs but I haven't tested that variant), but is not true for arguments given on the command-line.
I do think that it's useful to have path: and git+file: behave differently for the same path, and so writing path:<path> explicitly should behave as it does now. But the bare absolute path form should infer git+file: everywhere instead of just when used as CLI arguments, and the documentation should be updated such that it does not claim that path:<path> is equivalent to git+file://<path>, does not list the path: prefix as optional, and includes explicit documentation about how bare paths are interpreted.
Steps To Reproduce
Navigate to a directory on your local filesystem that contains a flake.
In the repl, run builtins.getFlake "/path/to/current/dir"
In the repl, run builtins.getFlake "path:/path/to/current/dir"
In the repl, run builtins.getFlake "git+file:///path/to/current/dir"
Expected behavior
Every means of evaluating a flake using an unprefixed path should behave identically to evaluating the flake using the git+file:// prefix (including resolved and locked URLs and other metadata). The flake evaluations using an explicit path: prefix should evaluate differently.
Describe the bug
nix help flakeexplains thatpath:<path>flakes are equivalent togit+file://<path>flakes with an inferreddirparameter if the path or any of its parents is a git repository. This does not appear to be true in general. Paths without thepath:prefix given to nix commands as arguments do infer thegit+filetype, but arguments with an explicitpath:don't, nor do paths specified in the nix registry or given tobuiltins.getFlake.So there's two issues here:
path:<path>andgit+file://<path>are roughly equivalent, except they're not as thepath:flake copies the entire referenced source directory whereasgit+file:copies the git worktree. This means the former will include untracked files that the latter skips (including the.gitdirectory itself), the metadata is different, and parameters like?rev=don't work (see builtins.getFlake doesn’t use git+file protocol if available #5670).<path>by itself is the same aspath:<path>(in that the specified URL form here is[path:]<path>(?<params>)?). This is true forbuiltins.getFlakeand for the registry (and presumably for flake inputs but I haven't tested that variant), but is not true for arguments given on the command-line.I do think that it's useful to have
path:andgit+file:behave differently for the same path, and so writingpath:<path>explicitly should behave as it does now. But the bare absolute path form should infergit+file:everywhere instead of just when used as CLI arguments, and the documentation should be updated such that it does not claim thatpath:<path>is equivalent togit+file://<path>, does not list thepath:prefix as optional, and includes explicit documentation about how bare paths are interpreted.Steps To Reproduce
nix flake metadata $PWDnix flake metadata path:$PWDnix flake metadata git+file://$PWDnix registry add foo $PWD && nix flake metadata foonix replbuiltins.getFlake "/path/to/current/dir"builtins.getFlake "path:/path/to/current/dir"builtins.getFlake "git+file:///path/to/current/dir"Expected behavior
Every means of evaluating a flake using an unprefixed path should behave identically to evaluating the flake using the
git+file://prefix (including resolved and locked URLs and other metadata). The flake evaluations using an explicitpath:prefix should evaluate differently.nix --versionoutputnix (Nix) 2.5.1