forked from yu-re-ka/binary-cache
feat(module): Add custom path info service option
This commit is contained in:
parent
fa45ea4779
commit
84e41704fd
2 changed files with 14 additions and 10 deletions
|
@ -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;
|
||||
};
|
||||
|
||||
|
|
|
@ -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}")
|
||||
'';
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue