mkOllamaModel: add diagnostics to help in packaging new models

This commit is contained in:
2024-12-05 21:46:17 +00:00
parent b0059e74dc
commit 94e44951f8

View File

@@ -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;