Skip to content

Commit 2d36679

Browse files
authored
Merge pull request #12468 from kip93/self-input-attrs-lfs
Add `inputs.self.lfs` flake attribute
2 parents 75db01c + 8b89c45 commit 2d36679

File tree

3 files changed

+40
-2
lines changed

3 files changed

+40
-2
lines changed
Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
11
---
22
synopsis: "Git LFS support"
3-
prs: [10153]
3+
prs: [10153, 12468]
44
---
55

66
The Git fetcher now supports Large File Storage (LFS). This can be enabled by passing the attribute `lfs = true` to the fetcher, e.g.
77
```console
88
nix flake prefetch 'git+ssh://[email protected]/Apress/repo-with-large-file-storage.git?lfs=1'
99
```
1010

11+
A flake can also declare that it requires lfs to be enabled:
12+
```
13+
{
14+
inputs.self.lfs = true;
15+
}
16+
```
17+
1118
Author: [**@b-camacho**](https://github.com/b-camacho), [**@kip93**](https://github.com/kip93)

src/libflake/flake/flake.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ static FlakeRef applySelfAttrs(
381381
{
382382
auto newRef(ref);
383383

384-
std::set<std::string> allowedAttrs{"submodules"};
384+
std::set<std::string> allowedAttrs{"submodules", "lfs"};
385385

386386
for (auto & attr : flake.selfAttrs) {
387387
if (!allowedAttrs.contains(attr.first))

tests/nixos/fetch-git/test-cases/lfs/default.nix

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,5 +193,36 @@
193193
194194
assert fetched_lfs == fetched_flake, \
195195
f"fetching as flake input (store path {fetched_flake}) yielded a different result than using fetchGit (store path {fetched_lfs})"
196+
197+
198+
with subtest("Check self.lfs"):
199+
client.succeed(f"""
200+
printf '{{
201+
inputs.self.lfs = true;
202+
outputs = {{ self }}: {{ }};
203+
}}' >{repo.path}/flake.nix
204+
""")
205+
client.succeed(f"{repo.git} add : >&2")
206+
client.succeed(f"{repo.git} commit -m 'add flake' >&2")
207+
client.succeed(f"{repo.git} push origin main >&2")
208+
209+
# memorize the revision
210+
self_lfs_rev = client.succeed(f"{repo.git} rev-parse HEAD").strip()
211+
212+
with TemporaryDirectory() as tempdir:
213+
client.succeed(f"mkdir -p {tempdir}")
214+
client.succeed(f"""
215+
printf '{{
216+
inputs.foo = {{
217+
url = "git+{repo.remote}?ref=main&rev={self_lfs_rev}";
218+
}};
219+
outputs = {{ foo, self }}: {{ inherit (foo) outPath; }};
220+
}}' >{tempdir}/flake.nix
221+
""")
222+
fetched_self_lfs = client.succeed(f"""
223+
nix eval --debug --raw {tempdir}#.outPath
224+
""")
225+
226+
client.succeed(f"cmp {repo.path}/beeg {fetched_self_lfs}/beeg >&2")
196227
'';
197228
}

0 commit comments

Comments
 (0)