{ pkgs, pkgs-unstable, pkgs-latest, lib, host, nvidia, ... }: 
let
  p = pkgs-latest.ollama;
  # p = pkgs-unstable.ollama.overrideAttrs (oldAttrs: rec {
  #   inherit (oldAttrs) pname;
  #   version = "0.3.0";
  #   src = pkgs.fetchFromGitHub {
  #     owner = "ollama";
  #     repo = "ollama";
  #     rev = "v${version}";
  #     hash = "sha256-69CpRAggx6a1NJq+CA9QliXuUbDgC1ERRuA3y17KVAM=";
  #     fetchSubmodules = true;
  #   };   
  # });
in {
  environment.systemPackages = [ p ];
  
  services.ollama = {
    package = p;
    enable = true;
    acceleration = lib.mkIf nvidia.enable "cuda";
    host = if host == "NxACE" then "0.0.0.0" else "127.0.0.1";
    port = 11434;
    environmentVariables = {
      OLLAMA_ORIGINS = "*"; 
    };
  };
}
