From b0369b28e34e3337f34d59d72cc2323a8997ff0d Mon Sep 17 00:00:00 2001 From: Paul Grandperrin Date: Fri, 21 Nov 2025 16:09:41 +0100 Subject: [PATCH 1/2] ollama-vulkan: set OLLAMA_VULKAN to 1 by default and add passthru test --- pkgs/by-name/ol/ollama/package.nix | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkgs/by-name/ol/ollama/package.nix b/pkgs/by-name/ol/ollama/package.nix index a386c5a81dca..2bb399e922cc 100644 --- a/pkgs/by-name/ol/ollama/package.nix +++ b/pkgs/by-name/ol/ollama/package.nix @@ -32,6 +32,7 @@ ollama, ollama-rocm, ollama-cuda, + ollama-vulkan, config, # one of `[ null false "rocm" "cuda" "vulkan" ]` @@ -119,6 +120,7 @@ let ] ++ lib.optionals enableVulkan [ "--suffix LD_LIBRARY_PATH : '${lib.makeLibraryPath (map lib.getLib vulkanLibs)}'" + "--set-default OLLAMA_VULKAN : '1'" ]; wrapperArgs = builtins.concatStringsSep " " wrapperOptions; @@ -268,10 +270,11 @@ goBuild (finalAttrs: { inherit ollama; } // lib.optionalAttrs stdenv.hostPlatform.isLinux { - inherit ollama-rocm ollama-cuda; + inherit ollama-rocm ollama-cuda ollama-vulkan; service = nixosTests.ollama; service-cuda = nixosTests.ollama-cuda; service-rocm = nixosTests.ollama-rocm; + service-vulkan = nixosTests.ollama-vulkan; }; } // lib.optionalAttrs (!enableRocm && !enableCuda) { updateScript = nix-update-script { }; }; From 7014a7115579d9537dce78f0f5083006e737fcad Mon Sep 17 00:00:00 2001 From: Paul Grandperrin Date: Fri, 21 Nov 2025 16:10:41 +0100 Subject: [PATCH 2/2] nixos/ollama: add vulkan acceleration option --- nixos/modules/services/misc/ollama.nix | 2 ++ nixos/tests/all-tests.nix | 1 + nixos/tests/ollama-vulkan.nix | 17 +++++++++++++++++ 3 files changed, 20 insertions(+) create mode 100644 nixos/tests/ollama-vulkan.nix diff --git a/nixos/modules/services/misc/ollama.nix b/nixos/modules/services/misc/ollama.nix index 6c45952b8ce7..9880da94e5c2 100644 --- a/nixos/modules/services/misc/ollama.nix +++ b/nixos/modules/services/misc/ollama.nix @@ -103,6 +103,7 @@ in false "rocm" "cuda" + "vulkan" ] ); default = null; @@ -119,6 +120,7 @@ in - may require overriding gpu type with `services.ollama.rocmOverrideGfx` if rocm doesn't detect your AMD gpu - `"cuda"`: supported by most modern NVIDIA GPUs + - `"vulkan"`: supported by most modern GPUs on Linux ''; }; rocmOverrideGfx = lib.mkOption { diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index ac16eaf315a7..c2044981638b 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -1136,6 +1136,7 @@ in ollama = runTest ./ollama.nix; ollama-cuda = runTestOn [ "x86_64-linux" "aarch64-linux" ] ./ollama-cuda.nix; ollama-rocm = runTestOn [ "x86_64-linux" "aarch64-linux" ] ./ollama-rocm.nix; + ollama-vulkan = runTestOn [ "x86_64-linux" "aarch64-linux" ] ./ollama-vulkan.nix; ombi = runTest ./ombi.nix; omnom = runTest ./omnom; oncall = runTest ./web-apps/oncall.nix; diff --git a/nixos/tests/ollama-vulkan.nix b/nixos/tests/ollama-vulkan.nix new file mode 100644 index 000000000000..c4f210ad26c8 --- /dev/null +++ b/nixos/tests/ollama-vulkan.nix @@ -0,0 +1,17 @@ +{ lib, ... }: +{ + name = "ollama-vulkan"; + meta.maintainers = with lib.maintainers; [ abysssol ]; + + nodes.vulkan = + { ... }: + { + services.ollama.enable = true; + services.ollama.acceleration = "vulkan"; + }; + + testScript = '' + vulkan.wait_for_unit("multi-user.target") + vulkan.wait_for_open_port(11434) + ''; +}