-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Description
Describe the bug
fetchTree since 358c26f has this ad hoc treatment of the shallow attribute:
// fetchTree should fetch git repos with shallow = true by default
if (type == "git" && !params.isFetchGit && !attrs.contains("shallow")) {
attrs.emplace("shallow", Explicit<bool>{true});
}This is bad because it makes fetchTree behave inconsistently with Git repos fetched in other ways. For example, when you add a flake input like
inputs.nixpkgs = { type = "git"; url = "git@github.com:NixOS/nixpkgs.git"; };
running a build/eval on this flake the first time will result in a cache path like
/home/eelco/.cache/nix/gitv3/1is1wr7j5dq4hnf6yhzrj2d6zv0874crgjrpg5jd9nwnkxzyg1fw
but the second time you get
/home/eelco/.cache/nix/gitv3/1is1wr7j5dq4hnf6yhzrj2d6zv0874crgjrpg5jd9nwnkxzyg1fw-shallow
(i.e. the repo will be cloned again.) This is because fetchTree is only used internally when an input is already locked. Similarly, nix flake metadata git+ssh://git@github.com/NixOS/nixpkgs.git doesn't use fetchTree.
builtins.fetchTree should never mess with the input attributes like this. Doing a shallow clone should be an optimization done in the git fetcher, if appropriate (e.g. if the revCount is already specified).
Steps To Reproduce
Expected behavior
Metadata
Additional context
Checklist
- checked latest Nix manual (source)
- checked open bug issues and pull requests for possible duplicates
Add 👍 to issues you find important.