Files
logos-chat-ui/flake.nix
osmaczko e6f2682e70 feat: take chat storage from the host-assigned session directory (#43)
* feat: take chat storage from the host-assigned session directory

The platform assigns every module instance its own persistence directory, so picking one here duplicated a decision the host had already made and left the init contract claiming an owner it did not have.

The standalone runner's `--user-dir` now selects the session directory the multi-instance dev and CI flows key off, so one host-level knob keeps two instances' state apart instead of a chat-specific environment variable.

* feat: stop choosing the delivery node's port

Running several instances on one host meant inventing a distinct delivery port for each and threading it through an environment variable, the docs, and both doc-test drivers, a coordination burden that bought nothing the transport cannot decide for itself.

chat_module's init no longer takes a port and its delivery node listens on ports it picks itself, so a session directory is the only thing that has to differ per instance.
2026-07-22 20:13:03 +02:00

78 lines
3.3 KiB
Nix

{
description = "Logos Chat UI - QML view + C++ backend module";
inputs = {
# Follow chat_module's own builder, so the logos-protocol/logos-qt-sdk
# chain matches across both.
logos-module-builder.follows = "chat_module/logos-module-builder";
# Pinned to the chat_module rev whose init contract drops the delivery port;
# release tags predate it.
chat_module.url = "github:logos-co/logos-chat-module/4983eb7343057bc12d51f6e7067ffb9cb681403a";
# Follow chat_module's delivery pin, so both build against the same
# delivery module.
logos-delivery-module.follows = "chat_module/logos-delivery-module";
};
outputs = inputs@{ logos-module-builder, logos-delivery-module, ... }:
let
base = logos-module-builder.lib.mkLogosQmlModule {
src = ./.;
configFile = ./metadata.json;
flakeInputs = { delivery_module = logos-delivery-module; } // inputs;
};
nixpkgs = logos-module-builder.inputs.nixpkgs;
# `nix run .#exchange`: drive the real two-party message round-trip and hold
# the receiving window open showing the result. The doc-test launches this
# to capture one post-exchange screenshot (see doctests/chat-ui-exchange.test.yaml);
# the full flow lives in docs/two-instance-exchange.md. APP_BIN is this
# flake's standalone runner; the driver scripts are bundled from
# ./doctests/exchange.
exchangeRunner = system:
let pkgs = import nixpkgs { inherit system; };
in pkgs.writeShellApplication {
name = "chat-ui-exchange";
runtimeInputs = with pkgs; [ nodejs coreutils util-linux procps bash ];
text = ''
export APP_BIN="${base.apps.${system}.default.program}"
exec bash ${./doctests/exchange}/run-exchange-show.sh "$@"
'';
};
# `nix run .#group`: form a real three-party group conversation and hold the
# newest member's window open showing the result. The doc-test launches this
# to capture one screenshot of the formed group (see
# doctests/chat-ui-group.test.yaml). APP_BIN is this flake's standalone
# runner; the driver scripts are bundled from ./doctests/group.
groupApp = system:
let
pkgs = import nixpkgs { inherit system; };
runner = pkgs.writeShellApplication {
name = "chat-ui-group";
runtimeInputs = with pkgs; [ nodejs coreutils util-linux procps bash ];
text = ''
export APP_BIN="${base.apps.${system}.default.program}"
exec bash ${./doctests/group}/run-group-show.sh "$@"
'';
};
in {
type = "app";
program = "${runner}/bin/chat-ui-group";
};
in
base // {
apps = builtins.mapAttrs
(system: sysApps: sysApps // {
exchange = { type = "app"; program = "${exchangeRunner system}/bin/chat-ui-exchange"; };
group = groupApp system;
})
base.apps;
# Also a package so `nix build .#exchange` resolves: the doc-test runner
# pre-builds its launch target that way to warm the store before the run.
packages = builtins.mapAttrs
(system: sysPkgs: sysPkgs // { exchange = exchangeRunner system; })
base.packages;
};
}