From a7bf5b975f3980677458c8cc5302393343d05fda Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Tue, 11 Jun 2024 16:47:09 +0300 Subject: test(tvix/glue/fetchurl): add output path tests for fetchurl These are all derived from the FOD representation of the ATerm serialization, so no new code necessary to calculate these hashes correctly. Change-Id: I8c5dacd2a8de3d5042c9dd56910511c19e1b9b31 Reviewed-on: https://cl.tvl.fyi/c/depot/+/11788 Reviewed-by: Connor Brewster Autosubmit: flokli Tested-by: BuildkiteCI --- .../src/tests/tvix_tests/eval-okay-fetchurl.nix | 40 ++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'tvix/glue/src/tests/tvix_tests/eval-okay-fetchurl.nix') diff --git a/tvix/glue/src/tests/tvix_tests/eval-okay-fetchurl.nix b/tvix/glue/src/tests/tvix_tests/eval-okay-fetchurl.nix index 8a3910152554..a3e9c5486968 100644 --- a/tvix/glue/src/tests/tvix_tests/eval-okay-fetchurl.nix +++ b/tvix/glue/src/tests/tvix_tests/eval-okay-fetchurl.nix @@ -22,4 +22,44 @@ name = "notmuch-extract-patch"; sha256 = "sha256-Xa1Jbl2Eq5+L0ww+Ph1osA3Z/Dxe/RkN1/dITQCdXFk="; }) + + # The following tests use . + # This is a piece of Nix code producing a "fake derivation" which gets + # handled by a "custom builder" that does the actual fetching. + # We access `.outPath` here, as the current string output of a Derivation + # still differs from the way nix presents it. + # It behaves similar to builtins.fetchurl, except it requires a hash to be + # provided upfront. + # If `unpack` is set to true, it can unpack NAR files (decompressing if + # necessary) + # If `executable` is set to true, it will place the fetched file at the root, + # but make it executable, and the hash is on the NAR representation. + + # Fetch a URL. + (import { + url = "https://test.example/owo"; + name = "notmuch-extract-patch"; + sha256 = "Xa1Jbl2Eq5+L0ww+Ph1osA3Z/Dxe/RkN1/dITQCdXFk="; + }).outPath + + # Fetch a NAR and unpack it, specifying the sha256 of its NAR representation. + (import { + url = "https://cache.nixos.org/nar/0r8nqa1klm5v17ifc6z96m9wywxkjvgbnqq9pmy0sgqj53wj3n12.nar.xz"; + sha256 = "sha256-oj6yfWKbcEerK8D9GdPJtIAOveNcsH1ztGeSARGypRA="; + unpack = true; + }).outPath + + # Fetch a NAR and unpack it, specifying its *sha1* of its NAR representation. + (import { + url = "https://cache.nixos.org/nar/0r8nqa1klm5v17ifc6z96m9wywxkjvgbnqq9pmy0sgqj53wj3n12.nar.xz"; + hash = "sha1-F/fMsgwkXF8fPCg1v9zPZ4yOFIA="; + unpack = true; + }).outPath + + # Fetch a URL, specifying the *sha1* of a NAR describing it as executable at the root. + (import { + url = "https://cache.nixos.org/nar/0r8nqa1klm5v17ifc6z96m9wywxkjvgbnqq9pmy0sgqj53wj3n12.nar.xz"; + hash = "sha1-NKNeU1csW5YJ4lCeWH3Z/apppNU="; + executable = true; + }).outPath ] -- cgit 1.4.1