From b2d352e6a35dec6d263a0c79e92db03114bdb356 Mon Sep 17 00:00:00 2001 From: Leandro Reina Date: Thu, 13 Feb 2025 17:59:27 +0100 Subject: [PATCH 1/3] Add `inputs.self.lfs` --- src/libflake/flake/flake.cc | 2 +- .../fetch-git/test-cases/lfs/default.nix | 31 +++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/src/libflake/flake/flake.cc b/src/libflake/flake/flake.cc index 443ad9a2a..ec0c8dde9 100644 --- a/src/libflake/flake/flake.cc +++ b/src/libflake/flake/flake.cc @@ -381,7 +381,7 @@ static FlakeRef applySelfAttrs( { auto newRef(ref); - std::set allowedAttrs{"submodules"}; + std::set allowedAttrs{"submodules", "lfs"}; for (auto & attr : flake.selfAttrs) { if (!allowedAttrs.contains(attr.first)) diff --git a/tests/nixos/fetch-git/test-cases/lfs/default.nix b/tests/nixos/fetch-git/test-cases/lfs/default.nix index a6b4fc77a..686796fcc 100644 --- a/tests/nixos/fetch-git/test-cases/lfs/default.nix +++ b/tests/nixos/fetch-git/test-cases/lfs/default.nix @@ -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") ''; } From 4a1d1c7f9f726a8365a3c1017a78d1718b54399c Mon Sep 17 00:00:00 2001 From: Leandro Reina Date: Thu, 13 Feb 2025 18:04:32 +0100 Subject: [PATCH 2/3] Add release note --- doc/manual/rl-next/self-lfs-attr.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 doc/manual/rl-next/self-lfs-attr.md diff --git a/doc/manual/rl-next/self-lfs-attr.md b/doc/manual/rl-next/self-lfs-attr.md new file mode 100644 index 000000000..0a2e878ff --- /dev/null +++ b/doc/manual/rl-next/self-lfs-attr.md @@ -0,0 +1,12 @@ +--- +synopsis: "`inputs.self.lfs` flake attribute" +prs: [12468] +--- + +Flakes in Git repositories can now declare that they need Git lfs to be enabled: +``` +{ + inputs.self.lfs = true; +} +``` +Thus, it's no longer needed for the caller of the flake to pass `lfs = true`. From 8b89c453b9d0df2a0b5eab31cedf16f981d03741 Mon Sep 17 00:00:00 2001 From: Leandro Reina Date: Fri, 14 Feb 2025 13:54:19 +0100 Subject: [PATCH 3/3] Merge release notes --- doc/manual/rl-next/git-lfs-support.md | 9 ++++++++- doc/manual/rl-next/self-lfs-attr.md | 12 ------------ 2 files changed, 8 insertions(+), 13 deletions(-) delete mode 100644 doc/manual/rl-next/self-lfs-attr.md diff --git a/doc/manual/rl-next/git-lfs-support.md b/doc/manual/rl-next/git-lfs-support.md index 2990fc76c..4b6e0ca86 100644 --- a/doc/manual/rl-next/git-lfs-support.md +++ b/doc/manual/rl-next/git-lfs-support.md @@ -1,6 +1,6 @@ --- 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. @@ -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' ``` +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) diff --git a/doc/manual/rl-next/self-lfs-attr.md b/doc/manual/rl-next/self-lfs-attr.md deleted file mode 100644 index 0a2e878ff..000000000 --- a/doc/manual/rl-next/self-lfs-attr.md +++ /dev/null @@ -1,12 +0,0 @@ ---- -synopsis: "`inputs.self.lfs` flake attribute" -prs: [12468] ---- - -Flakes in Git repositories can now declare that they need Git lfs to be enabled: -``` -{ - inputs.self.lfs = true; -} -``` -Thus, it's no longer needed for the caller of the flake to pass `lfs = true`.