ollama: use finalAttrs and fix version overriding

This commit is contained in:
Yueh-Shun Li
2025-04-21 21:11:41 +02:00
committed by Pavol Rusnak
parent b362e0e3ea
commit a31997af3b
+19 -26
View File
@@ -40,20 +40,6 @@ assert builtins.elem acceleration [
];
let
pname = "ollama";
# don't forget to invalidate all hashes each update
version = "0.6.5";
src = fetchFromGitHub {
owner = "ollama";
repo = "ollama";
tag = "v${version}";
hash = "sha256-l+JYQjl6A0fKONxtgCtc0ztT18rmArGKcO2o+p4H95M=";
fetchSubmodules = true;
};
vendorHash = "sha256-4wYgtdCHvz+ENNMiHptu6ulPJAznkWetQcdba3IEB6s=";
validateFallback = lib.warnIf (config.rocmSupport && config.cudaSupport) (lib.concatStrings [
"both `nixpkgs.config.rocmSupport` and `nixpkgs.config.cudaSupport` are enabled, "
"but they are mutually exclusive; falling back to cpu"
@@ -136,13 +122,20 @@ let
buildGoModule;
inherit (lib) licenses platforms maintainers;
in
goBuild {
inherit
pname
version
src
vendorHash
;
goBuild (finalAttrs: {
pname = "ollama";
# don't forget to invalidate all hashes each update
version = "0.6.5";
src = fetchFromGitHub {
owner = "ollama";
repo = "ollama";
tag = "v${finalAttrs.version}";
hash = "sha256-l+JYQjl6A0fKONxtgCtc0ztT18rmArGKcO2o+p4H95M=";
fetchSubmodules = true;
};
vendorHash = "sha256-4wYgtdCHvz+ENNMiHptu6ulPJAznkWetQcdba3IEB6s=";
env =
lib.optionalAttrs enableRocm {
@@ -184,7 +177,7 @@ goBuild {
# replace inaccurate version number with actual release version
postPatch = ''
substituteInPlace version/version.go \
--replace-fail 0.0.0 '${version}'
--replace-fail 0.0.0 '${finalAttrs.version}'
'';
overrideModAttrs = (
@@ -240,7 +233,7 @@ goBuild {
ldflags = [
"-s"
"-w"
"-X=github.com/ollama/ollama/version.Version=${version}"
"-X=github.com/ollama/ollama/version.Version=${finalAttrs.version}"
"-X=github.com/ollama/ollama/server.mode=release"
];
@@ -251,7 +244,7 @@ goBuild {
{
inherit ollama;
version = testers.testVersion {
inherit version;
inherit (finalAttrs) version;
package = ollama;
};
}
@@ -269,7 +262,7 @@ goBuild {
+ lib.optionalString rocmRequested ", using ROCm for AMD GPU acceleration"
+ lib.optionalString cudaRequested ", using CUDA for NVIDIA GPU acceleration";
homepage = "https://github.com/ollama/ollama";
changelog = "https://github.com/ollama/ollama/releases/tag/v${version}";
changelog = "https://github.com/ollama/ollama/releases/tag/v${finalAttrs.version}";
license = licenses.mit;
platforms = if (rocmRequested || cudaRequested) then platforms.linux else platforms.unix;
mainProgram = "ollama";
@@ -281,4 +274,4 @@ goBuild {
roydubnium
];
};
}
})