diff --git a/pkgs/by-name/ollamaPackages/mkOllamaModel.nix b/pkgs/by-name/ollamaPackages/mkOllamaModel.nix index 6a72ec9c3..59080029b 100644 --- a/pkgs/by-name/ollamaPackages/mkOllamaModel.nix +++ b/pkgs/by-name/ollamaPackages/mkOllamaModel.nix @@ -92,26 +92,46 @@ stdenv.mkDerivation { echo "manifest:" cat manifest - printBlob() { + mismatchedBlobs=() + checkBlob() { local blobType="$1" + local expectedBlobHash="$2" 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 + + if [ "''${blobHash//\"/}" != "$expectedBlobHash" ]; then + mismatchedBlobs+=("$blobType") + fi } echo "blobs:" - printBlob model - printBlob params - printBlob system - printBlob ensureDoesntFailForNonExistentBlob + checkBlob model "$modelBlob" + checkBlob params "$paramsBlob" + checkBlob system "$systemBlob" + checkBlob ensureDoesntFailForNonExistentBlob + + if [ -n "$mismatchedBlobs" ]; then + echo "mismatched blobs:" + for b in "''${mismatchedBlobs[@]}"; do + echo "- $b" + done + false + fi runHook postCheck ''; doCheck = true; - env.blobDir = "share/ollama/models/blobs"; - env.manifestDir = "share/ollama/models/manifests/registry.ollama.ai/library/${modelName}"; - env.variant = variant; + env = { + blobDir = "share/ollama/models/blobs"; + manifestDir = "share/ollama/models/manifests/registry.ollama.ai/library/${modelName}"; + inherit variant modelBlob paramsBlob systemBlob; + }; + + meta = { + homepage = "https://ollama.com/library/${modelName}"; + }; }