Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion doc/manual/rl-next/git-lfs-support.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
---
synopsis: "Git LFS support"
prs: [10153]
prs: [10153, 12468]
---

The Git fetcher now supports Large File Storage (LFS). This can be enabled by passing the attribute `lfs = true` to the fetcher, e.g.
```console
nix flake prefetch 'git+ssh://git@github.com/Apress/repo-with-large-file-storage.git?lfs=1'
```

A flake can also declare that it requires lfs to be enabled:
```
{
inputs.self.lfs = true;
}
```

Author: [**@b-camacho**](https://github.com/b-camacho), [**@kip93**](https://github.com/kip93)
2 changes: 1 addition & 1 deletion src/libflake/flake/flake.cc
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ static FlakeRef applySelfAttrs(
{
auto newRef(ref);

std::set<std::string> allowedAttrs{"submodules"};
std::set<std::string> allowedAttrs{"submodules", "lfs"};

for (auto & attr : flake.selfAttrs) {
if (!allowedAttrs.contains(attr.first))
Expand Down
31 changes: 31 additions & 0 deletions tests/nixos/fetch-git/test-cases/lfs/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -193,5 +193,36 @@

assert fetched_lfs == fetched_flake, \
f"fetching as flake input (store path {fetched_flake}) yielded a different result than using fetchGit (store path {fetched_lfs})"


with subtest("Check self.lfs"):
client.succeed(f"""
printf '{{
inputs.self.lfs = true;
outputs = {{ self }}: {{ }};
}}' >{repo.path}/flake.nix
""")
client.succeed(f"{repo.git} add : >&2")
client.succeed(f"{repo.git} commit -m 'add flake' >&2")
client.succeed(f"{repo.git} push origin main >&2")

# memorize the revision
self_lfs_rev = client.succeed(f"{repo.git} rev-parse HEAD").strip()

with TemporaryDirectory() as tempdir:
client.succeed(f"mkdir -p {tempdir}")
client.succeed(f"""
printf '{{
inputs.foo = {{
url = "git+{repo.remote}?ref=main&rev={self_lfs_rev}";
}};
outputs = {{ foo, self }}: {{ inherit (foo) outPath; }};
}}' >{tempdir}/flake.nix
""")
fetched_self_lfs = client.succeed(f"""
nix eval --debug --raw {tempdir}#.outPath
""")

client.succeed(f"cmp {repo.path}/beeg {fetched_self_lfs}/beeg >&2")
'';
}
Loading