From 84e41704fd328dcf80470b26f75a26e90147a99f Mon Sep 17 00:00:00 2001 From: sinavir Date: Sat, 20 Jul 2024 15:59:30 +0200 Subject: [PATCH] feat(module): Add custom path info service option --- modules/default.nix | 20 ++++++++++++-------- tests/ingest.nix | 4 ++-- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/modules/default.nix b/modules/default.nix index 6404c59..e166f11 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -58,6 +58,11 @@ in default = name; defaultText = lib.literalMD "Defaults to attribute name in services.tvix-binary-cache.caches"; }; + path-info-service-addr = lib.mkOption { + type = with lib.types; str; + description = "Path info service path"; + default = "sled://%S/%N/pathinfo.sled"; + }; remote-path-info-service-addr = lib.mkOption { type = with lib.types; nullOr str; description = "Upstream cache to substitute from if nothing in "; @@ -113,7 +118,7 @@ in ++ (lib.mapAttrsToList ( name: cfg: let - stateDir = "tvix-binary-cache-${cfg.name}"; + unitName = "tvix-store-${cfg.name}"; in { "nar-bridge-${cfg.name}" = { @@ -121,13 +126,13 @@ in wantedBy = [ "multi-user.target" ]; after = [ "tvix-store-${cfg.name}.service" ]; serviceConfig = rec { - ExecStart = "${lib.getExe pkgs.nar-bridge-go} --otlp=false --listen-addr=\"[::1]:${builtins.toString cfg.port}\" --store-addr=\"unix://%t/${stateDir}/socket\""; + ExecStart = "${lib.getExe pkgs.nar-bridge-go} --otlp=false --listen-addr=\"[::1]:${builtins.toString cfg.port}\" --store-addr=\"unix://%t/${unitName}/socket\""; DynamicUser = true; User = "tvix-binary-cache"; } // systemdHardening; }; - "tvix-store-${cfg.name}" = { + ${unitName} = { wants = [ "tvix-castore.service" ]; after = [ "tvix-castore.service" ]; environment = { @@ -141,18 +146,17 @@ in cfg.directory-service-addr else "grpc+unix://%t/tvix-castore/socket"; - PATH_INFO_SERVICE_ADDR = "sled://%S/${stateDir}/pathinfo.sled"; + PATH_INFO_SERVICE_ADDR = cfg.path-info-service-addr; REMOTE_PATH_INFO_SERVICE_ADDR = lib.mkIf ( cfg.remote-path-info-service-addr != null ) cfg.remote-path-info-service-addr; }; serviceConfig = { - ExecStart = "${pkgs.tvix-store}/bin/tvix-store --otlp=false daemon --listen-address=\"%t/${stateDir}/socket\""; - + ExecStart = "${pkgs.tvix-store}/bin/tvix-store --otlp=false daemon --listen-address=\"%t/${unitName}/socket\""; DynamicUser = true; User = "tvix-binary-cache"; - StateDirectory = stateDir; - RuntimeDirectory = stateDir; + StateDirectory = unitName; + RuntimeDirectory = unitName; } // systemdHardening; }; diff --git a/tests/ingest.nix b/tests/ingest.nix index 53286db..2888637 100644 --- a/tests/ingest.nix +++ b/tests/ingest.nix @@ -9,7 +9,7 @@ let } "jq -r \"{closure : .hello}\" < .attrs.json > $out"; # "jq -r '.hello' < .attrs.json > $out"; in pkgs.testers.runNixOSTest (_: { - name = "cache signature upload test"; + name = "ingestion with tvix copy"; nodes = { cache = { imports = [ @@ -43,7 +43,7 @@ pkgs.testers.runNixOSTest (_: { 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" + socket_addr = "grpc+unix:///run/tvix-store-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}") ''; })