From 3a0c35bf688c84397d84c2bf3f1d17994e46755a Mon Sep 17 00:00:00 2001 From: joshp123 Date: Wed, 6 May 2026 11:09:33 +0200 Subject: [PATCH] Fix QMD model prewarm activation Use QMD's real update/embed/query commands instead of the nonexistent qmd pull path, and keep the activation script in nix/scripts instead of inline Nix. Tests: nix build .#checks.aarch64-darwin.config-validity .#checks.aarch64-darwin.qmd-runtime --no-link; nix eval .#checks.x86_64-linux.qmd-runtime.name; scripts/check-flake-lock-owners.sh; git diff --check --- README.md | 5 ++++- nix/checks/openclaw-default-instance.nix | 7 +++++-- nix/modules/home-manager/openclaw/config.nix | 3 ++- nix/scripts/openclaw-qmd-prewarm.sh | 22 ++++++++++++++++++++ 4 files changed, 33 insertions(+), 4 deletions(-) create mode 100644 nix/scripts/openclaw-qmd-prewarm.sh diff --git a/README.md b/README.md index ab25c6b..99218e6 100644 --- a/README.md +++ b/README.md @@ -726,7 +726,10 @@ Optional model prewarming is also declarative: programs.openclaw.qmd.prewarmModels.enable = true; ``` -That runs `qmd pull` during Home Manager activation and stores the default embedding, expansion, and reranking models in the user's QMD cache. Expect about 2.25GB of cache use. +That runs a temporary QMD collection through `qmd update`, `qmd embed`, and +`qmd query` during Home Manager activation, which warms the default embedding, +expansion, and reranking models in the user's QMD cache. Expect about 2.25GB of +cache use. ### What we manage vs what you manage diff --git a/nix/checks/openclaw-default-instance.nix b/nix/checks/openclaw-default-instance.nix index 14d825d..ea8c58e 100644 --- a/nix/checks/openclaw-default-instance.nix +++ b/nix/checks/openclaw-default-instance.nix @@ -212,10 +212,13 @@ let qmdPrewarmCheck = builtins.deepSeq (requireNoAssertionFailures "qmd.prewarmModels" qmdPrewarmEval) ( - if lib.hasInfix "/bin/qmd pull" qmdPrewarmActivation then + if + lib.hasInfix "OPENCLAW_QMD_BIN=" qmdPrewarmActivation + && lib.hasInfix "openclaw-qmd-prewarm.sh" qmdPrewarmActivation + then "ok" else - throw "qmd.prewarmModels did not wire qmd pull activation." + throw "qmd.prewarmModels did not wire QMD model-cache prewarm activation." ); checkKey = builtins.deepSeq [ diff --git a/nix/modules/home-manager/openclaw/config.nix b/nix/modules/home-manager/openclaw/config.nix index b592b8a..8e79395 100644 --- a/nix/modules/home-manager/openclaw/config.nix +++ b/nix/modules/home-manager/openclaw/config.nix @@ -332,7 +332,8 @@ in XDG_CACHE_HOME=${lib.escapeShellArg "${homeDir}/.cache"} \ XDG_CONFIG_HOME=${lib.escapeShellArg "${homeDir}/.config"} \ XDG_DATA_HOME=${lib.escapeShellArg "${homeDir}/.local/share"} \ - ${qmdPackage}/bin/qmd pull + OPENCLAW_QMD_BIN=${lib.escapeShellArg "${qmdPackage}/bin/qmd"} \ + ${pkgs.bash}/bin/bash ${../../../scripts/openclaw-qmd-prewarm.sh} '' ); diff --git a/nix/scripts/openclaw-qmd-prewarm.sh b/nix/scripts/openclaw-qmd-prewarm.sh new file mode 100644 index 0000000..c2f3b04 --- /dev/null +++ b/nix/scripts/openclaw-qmd-prewarm.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash +set -euo pipefail + +qmd="${OPENCLAW_QMD_BIN:?OPENCLAW_QMD_BIN is required}" +tmp_dir="$(mktemp -d)" + +cleanup() { + rm -rf "$tmp_dir" + "$qmd" collection remove openclaw-prewarm >/dev/null 2>&1 || true +} +trap cleanup EXIT + +printf "%s\n\n%s\n" \ + "# OpenClaw QMD prewarm" \ + "This temporary document warms QMD model caches." \ + > "$tmp_dir/prewarm.md" + +"$qmd" collection remove openclaw-prewarm >/dev/null 2>&1 || true +"$qmd" collection add "$tmp_dir" --name openclaw-prewarm >/dev/null +"$qmd" update >/dev/null +"$qmd" embed >/dev/null +"$qmd" query "OpenClaw QMD prewarm" -n 1 --json >/dev/null