From cc588a19475c0bd35ff766b38ebe1769cac97459 Mon Sep 17 00:00:00 2001 From: Alexandre Date: Fri, 26 Dec 2025 23:45:13 +0100 Subject: [PATCH] Fixed ollama package --- hosts/macos/modules.nix | 4 +++- hosts/nixos/modules.nix | 4 +++- modules/common/ai.nix | 16 ++++++++++++++-- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/hosts/macos/modules.nix b/hosts/macos/modules.nix index 27985df..ef3abec 100644 --- a/hosts/macos/modules.nix +++ b/hosts/macos/modules.nix @@ -1,6 +1,8 @@ +{ pkgs ,... }: + { # Enpty file for future imports imports = [ - (import ../../common/ai.nix { gpu = "metal"; }) + (import ../../common/ai.nix { inherit pkgs; }) ]; } diff --git a/hosts/nixos/modules.nix b/hosts/nixos/modules.nix index c077315..99d9b4b 100644 --- a/hosts/nixos/modules.nix +++ b/hosts/nixos/modules.nix @@ -1,3 +1,5 @@ +{ pkgs ,... }: + { # This file is used to import all modules required by this setup. imports = @@ -8,6 +10,6 @@ ../../modules/nixos/gamming/steam.nix # For Steam/Proton/Lutris/MangoHUD/Heroic/Bottles ../../modules/common/spotify.nix # Spotify/Spicetify ../../modules/common/ssh.nix - (import ../../modules/common/ai.nix { gpu = "cuda"; }) + (import ../../modules/common/ai.nix { inherit pkgs; }) ]; } diff --git a/modules/common/ai.nix b/modules/common/ai.nix index a967507..8312048 100644 --- a/modules/common/ai.nix +++ b/modules/common/ai.nix @@ -1,11 +1,23 @@ -{ gpu, ... }: +{ pkgs, ... }: +let + # Détection simple du GPU pour choisir le package Ollama + gpu = + if builtins.hasAttr "nvidia" pkgs then + pkgs.ollama-cuda + else if builtins.hasAttr "vulkan" pkgs then + pkgs.ollama-vulkan + else if builtins.hasAttr "rocm" pkgs then + pkgs.ollama-rocm + else + pkgs.ollama; # CPU fallback +in { services = { ollama = { enable = true; loadModels = [ "codegemma:7b-instruct" "codegemma:7b-code" "codegemma:2b" "starcoder2:7b" ]; - acceleration = gpu; + package = gpu; }; open-webui = { enable = true;