From c686de6505f96982c0600c121277f7b5a30fc371 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Fri, 9 May 2025 16:44:48 +0200 Subject: [PATCH 1/2] nix flake prefetch: Remove __final This is currently an internal attribute, not intended to be shown to users. Fixes #13150. --- src/nix/flake.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/src/nix/flake.cc b/src/nix/flake.cc index 351b2caaf..80ff111f1 100644 --- a/src/nix/flake.cc +++ b/src/nix/flake.cc @@ -1497,6 +1497,7 @@ struct CmdFlakePrefetch : FlakeCommand, MixJSON res["hash"] = hash.to_string(HashFormat::SRI, true); res["original"] = fetchers::attrsToJSON(resolvedRef.toAttrs()); res["locked"] = fetchers::attrsToJSON(lockedRef.toAttrs()); + res["locked"].erase("__final"); // internal for now printJSON(res); } else { notice("Downloaded '%s' to '%s' (hash '%s').", From da953d6d39f830f7edd2e9c2505bc86af4fabda3 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Fri, 9 May 2025 16:55:13 +0200 Subject: [PATCH 2/2] Add test --- tests/functional/tarball.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/functional/tarball.sh b/tests/functional/tarball.sh index 53807603c..6b09cf6a5 100755 --- a/tests/functional/tarball.sh +++ b/tests/functional/tarball.sh @@ -73,7 +73,8 @@ test_tarball .gz gzip # All entries in tree.tar.gz refer to the same file, and all have the same inode when unpacked by GNU tar. # We don't preserve the hard links, because that's an optimization we think is not worth the complexity, # so we only make sure that the contents are copied correctly. -nix flake prefetch --json "tarball+file://$(pwd)/tree.tar.gz" --out-link "$TEST_ROOT/result" +json=$(nix flake prefetch --json "tarball+file://$(pwd)/tree.tar.gz" --out-link "$TEST_ROOT/result") +[[ $json =~ ^'{"hash":"sha256-'.*'","locked":{"lastModified":'.*',"narHash":"sha256-'.*'","type":"tarball","url":"file:///'.*'/tree.tar.gz"},"original":{"type":"tarball","url":"file:///'.*'/tree.tar.gz"},"storePath":"'.*'/store/'.*'-source"}'$ ]] [[ $(cat "$TEST_ROOT/result/a/b/foo") = bar ]] [[ $(cat "$TEST_ROOT/result/a/b/xyzzy") = bar ]] [[ $(cat "$TEST_ROOT/result/a/yyy") = bar ]]