From d5d34b2b835b4ca3c04609dcf9b8172760cfde06 Mon Sep 17 00:00:00 2001 From: sinavir Date: Thu, 18 Jul 2024 16:57:05 +0200 Subject: [PATCH] feat: Add tvix-store cli to system packages --- modules/default.nix | 2 ++ tests/default.nix | 1 + tests/ingest.nix | 61 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 64 insertions(+) create mode 100644 tests/ingest.nix diff --git a/modules/default.nix b/modules/default.nix index 4c51636..1aedf25 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -68,6 +68,8 @@ in config = lib.mkIf cfg.enable { + environment.systemPackages = [ pkgs.tvix-store ]; + systemd.services = lib.mkMerge ( (lib.singleton { tvix-castore = { diff --git a/tests/default.nix b/tests/default.nix index 6278595..6e39f47 100644 --- a/tests/default.nix +++ b/tests/default.nix @@ -5,5 +5,6 @@ let in { basic = pkgs.callPackage ./basic.nix { }; + ingest = pkgs.callPackage ./ingest.nix { }; signature = pkgs.callPackage ./signature.nix { }; } diff --git a/tests/ingest.nix b/tests/ingest.nix new file mode 100644 index 0000000..ad281b3 --- /dev/null +++ b/tests/ingest.nix @@ -0,0 +1,61 @@ +{ pkgs }: +let + #hello = pkgs.hello.overrideAttrs { pname = "custom-hello"; }; + inherit (pkgs) hello; + references = pkgs.runCommandNoCC "hello-refs" { + exportReferencesGraph.hello = hello; + __structuredAttrs = true; + nativeBuildInputs = [ pkgs.jq ]; + } "jq -r \"{closure : .hello}\" < .attrs.json > $out"; # "jq -r '.hello' < .attrs.json > $out"; +in +pkgs.testers.runNixOSTest (_: { + name = "cache signature upload test"; + nodes = { + cache = + { config, ... }: + { + imports = [ + ./common + ../modules + ]; + + system.extraDependencies = [ + hello + references + ]; + + services.tvix-binary-cache = { + enable = true; + caches = { + cache.port = 8000; + }; + }; + + services.nginx = { + enable = true; + recommendedProxySettings = true; + virtualHosts.cache = { + default = true; + locations = { + "/cache".return = "302 /cache/"; + "/cache/" = { + proxyPass = "http://localhost:${toString config.services.tvix-binary-cache.caches.cache.port}/"; + }; + }; + extraConfig = "client_max_body_size 1G;"; + + }; + }; + networking.firewall.allowedTCPPorts = [ 80 ]; + }; + }; + testScript = '' + import time + start_all() + cache.wait_for_unit("nginx.service") + cache.wait_for_unit("nar-bridge-cache.service") + time.sleep(1) + socket_addr = "grpc+unix:///run/tvix-binary-cache-cache/socket" + cache.succeed(f"BLOB_SERVICE_ADDR={socket_addr} DIRECTORY_SERVICE_ADDR={socket_addr} PATH_INFO_SERVICE_ADDR={socket_addr} tvix-store copy ${builtins.toString references}") + ''; +})