|
|
|
@@ -3,6 +3,8 @@
|
|
|
|
|
let
|
|
|
|
|
pkgs = config.nodes.machine.nixpkgs.pkgs;
|
|
|
|
|
|
|
|
|
|
lastModified = builtins.toString nixpkgs.lastModified;
|
|
|
|
|
|
|
|
|
|
root = pkgs.runCommand "nixpkgs-flake" {}
|
|
|
|
|
''
|
|
|
|
|
mkdir -p $out/{stable,tags}
|
|
|
|
@@ -19,7 +21,7 @@ let
|
|
|
|
|
# arbitrary headers.
|
|
|
|
|
cat >$out/tags/.htaccess <<EOF
|
|
|
|
|
Redirect "/tags/latest.tar.gz" "/stable/${nixpkgs.rev}.tar.gz"
|
|
|
|
|
Header always set Link "<http://localhost/stable/${nixpkgs.rev}.tar.gz?rev=${nixpkgs.rev}&revCount=1234>; rel=\"immutable\""
|
|
|
|
|
Header always set Link "<http://localhost/stable/${nixpkgs.rev}.tar.gz?rev=${nixpkgs.rev}&revCount=1234&lastModified=${lastModified}>; rel=\"immutable\""
|
|
|
|
|
EOF
|
|
|
|
|
'';
|
|
|
|
|
in
|
|
|
|
@@ -69,23 +71,27 @@ in
|
|
|
|
|
|
|
|
|
|
# Check that we got redirected to the immutable URL.
|
|
|
|
|
locked_url = info["locked"]["url"]
|
|
|
|
|
assert locked_url == "http://localhost/stable/${nixpkgs.rev}.tar.gz?rev=${nixpkgs.rev}&revCount=1234", f"{locked_url=} != http://localhost/stable/${nixpkgs.rev}.tar.gz"
|
|
|
|
|
assert locked_url == "http://localhost/stable/${nixpkgs.rev}.tar.gz?lastModified=${lastModified}&rev=${nixpkgs.rev}&revCount=1234", f"{locked_url=} != http://localhost/stable/${nixpkgs.rev}.tar.gz"
|
|
|
|
|
|
|
|
|
|
# Check that we got the rev and revCount attributes.
|
|
|
|
|
# Check that we got the right attributes.
|
|
|
|
|
revision = info["revision"]
|
|
|
|
|
rev_count = info["revCount"]
|
|
|
|
|
last_modified = info["lastModified"]
|
|
|
|
|
assert revision == "${nixpkgs.rev}", f"{revision=} != ${nixpkgs.rev}"
|
|
|
|
|
assert rev_count == 1234, f"{rev_count=} != 1234"
|
|
|
|
|
assert last_modified == ${lastModified}, f"{last_modified=} != ${lastModified}"
|
|
|
|
|
|
|
|
|
|
# Check that fetching with rev/revCount/narHash succeeds.
|
|
|
|
|
machine.succeed("nix flake metadata --json http://localhost/tags/latest.tar.gz?rev=" + revision)
|
|
|
|
|
machine.succeed("nix flake metadata --json http://localhost/tags/latest.tar.gz?revCount=" + str(rev_count))
|
|
|
|
|
machine.succeed("nix flake metadata --json http://localhost/tags/latest.tar.gz?narHash=" + info["locked"]["narHash"])
|
|
|
|
|
machine.succeed("nix flake metadata --json http://localhost/tags/latest.tar.gz?lastModified=" + str(last_modified))
|
|
|
|
|
|
|
|
|
|
# Check that fetching fails if we provide incorrect attributes.
|
|
|
|
|
machine.fail("nix flake metadata --json http://localhost/tags/latest.tar.gz?rev=493300eb13ae6fb387fbd47bf54a85915acc31c0")
|
|
|
|
|
machine.fail("nix flake metadata --json http://localhost/tags/latest.tar.gz?revCount=789")
|
|
|
|
|
machine.fail("nix flake metadata --json http://localhost/tags/latest.tar.gz?narHash=sha256-tbudgBSg+bHWHiHnlteNzN8TUvI80ygS9IULh4rklEw=")
|
|
|
|
|
machine.fail("nix flake metadata --json http://localhost/tags/latest.tar.gz?lastModified=1111111111")
|
|
|
|
|
'';
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|