From 94e44951f8cf15f1af2d97173c7463a5cda103e4 Mon Sep 17 00:00:00 2001 From: Colin Date: Thu, 5 Dec 2024 21:46:17 +0000 Subject: [PATCH] mkOllamaModel: add diagnostics to help in packaging new models --- pkgs/by-name/ollamaPackages/mkOllamaModel.nix | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/pkgs/by-name/ollamaPackages/mkOllamaModel.nix b/pkgs/by-name/ollamaPackages/mkOllamaModel.nix index a0102bf72..6a72ec9c3 100644 --- a/pkgs/by-name/ollamaPackages/mkOllamaModel.nix +++ b/pkgs/by-name/ollamaPackages/mkOllamaModel.nix @@ -85,6 +85,32 @@ stdenv.mkDerivation { runHook postInstall ''; + checkPhase = '' + runHook preCheck + + # diagnostics for when packaging models: use the manifestBlob, systemBlob output here in your nix expression + echo "manifest:" + cat manifest + + printBlob() { + local blobType="$1" + local blobHash=$(cat manifest | jq ".layers.[] | select(.mediaType == \"application/vnd.ollama.image.$blobType\") | .digest[7:]") + if [ -n "$blobHash" ]; then + printf " %sBlob = %s;\n" "$blobType" "$blobHash" + fi + } + + echo "blobs:" + printBlob model + printBlob params + printBlob system + printBlob ensureDoesntFailForNonExistentBlob + + runHook postCheck + ''; + + doCheck = true; + env.blobDir = "share/ollama/models/blobs"; env.manifestDir = "share/ollama/models/manifests/registry.ollama.ai/library/${modelName}"; env.variant = variant;