1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-07-07 10:11:47 +02:00

Merge pull request #12468 from kip93/self-input-attrs-lfs

Add `inputs.self.lfs` flake attribute
This commit is contained in:
Robert Hensing 2025-02-15 17:30:57 +01:00 committed by GitHub
commit 2d36679663
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 40 additions and 2 deletions

View file

@ -1,6 +1,6 @@
--- ---
synopsis: "Git LFS support" 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. The Git fetcher now supports Large File Storage (LFS). This can be enabled by passing the attribute `lfs = true` to the fetcher, e.g.
@ -8,4 +8,11 @@ The Git fetcher now supports Large File Storage (LFS). This can be enabled by pa
nix flake prefetch 'git+ssh://git@github.com/Apress/repo-with-large-file-storage.git?lfs=1' 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) Author: [**@b-camacho**](https://github.com/b-camacho), [**@kip93**](https://github.com/kip93)

View file

@ -381,7 +381,7 @@ static FlakeRef applySelfAttrs(
{ {
auto newRef(ref); auto newRef(ref);
std::set<std::string> allowedAttrs{"submodules"}; std::set<std::string> allowedAttrs{"submodules", "lfs"};
for (auto & attr : flake.selfAttrs) { for (auto & attr : flake.selfAttrs) {
if (!allowedAttrs.contains(attr.first)) if (!allowedAttrs.contains(attr.first))

View file

@ -193,5 +193,36 @@
assert fetched_lfs == fetched_flake, \ 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})" 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")
''; '';
} }