From 608f8008ebd5e7a535544cbc8df18ea4a64bb66a Mon Sep 17 00:00:00 2001 From: Yureka Date: Mon, 22 Jul 2024 01:39:53 +0200 Subject: [PATCH] feat(module): expose common-composition to the user --- modules/default.nix | 66 ++++++++++++++++++++++++--------------------- 1 file changed, 35 insertions(+), 31 deletions(-) diff --git a/modules/default.nix b/modules/default.nix index bb7dee7..8630bac 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -41,6 +41,7 @@ in options = { grpcListenAddress = lib.mkOption { type = lib.types.str; }; narBridgeListenAddress = lib.mkOption { type = lib.types.str; }; + common-composition = lib.mkOption { inherit (settingsFormat) type; }; nar-bridge-composition = lib.mkOption { inherit (settingsFormat) type; }; tvix-daemon-composition = lib.mkOption { inherit (settingsFormat) type; }; name = lib.mkOption { @@ -57,38 +58,37 @@ in }; }; - config = - let - common-composition = { - blobservices.default = { + config = { + common-composition = { + blobservices.default = { + type = "objectstore"; + object_store_url = "file://${cfg.castoreDir}/blobs.object-store"; + object_store_options = { }; + }; + directoryservices = { + objectstore = { type = "objectstore"; - object_store_url = "file://${cfg.castoreDir}/blobs.object-store"; + object_store_url = "file://${cfg.castoreDir}/directories.object-store"; object_store_options = { }; }; - directoryservices = { - objectstore = { - type = "objectstore"; - object_store_url = "file://${cfg.castoreDir}/directories.object-store"; - object_store_options = { }; - }; - memory = { - type = "memory"; - }; - cache = { - type = "cache"; - near = "memory"; - far = "objectstore"; - }; - default = { - type = "router"; - writes = "objectstore"; - reads = "cache"; - }; + memory = { + type = "memory"; + }; + cache = { + type = "cache"; + near = "memory"; + far = "objectstore"; + }; + default = { + type = "router"; + writes = "objectstore"; + reads = "cache"; }; }; - in - { - nar-bridge-composition = lib.recursiveUpdate common-composition { + }; + nar-bridge-composition = lib.mkMerge [ + cacheAttrs.config.common-composition + { pathinfoservices.default = { type = "grpc"; url = "grpc+http://${ @@ -104,15 +104,19 @@ in cacheAttrs.config.grpcListenAddress }"; }; - }; - tvix-daemon-composition = lib.recursiveUpdate common-composition { + } + ]; + tvix-daemon-composition = lib.mkMerge [ + cacheAttrs.config.common-composition + { pathinfoservices.default = { type = "sled"; is_temporary = false; path = "/var/lib/tvix-daemon-${name}/pathinfos.sled"; }; - }; - }; + } + ]; + }; } ) );