{ config, lib, ... }:
{
  options.ollama.enable = lib.mkEnableOption "Enable Ollama server /w GPU acceleration";

  config.services.ollama = lib.mkIf config.ollama.enable {
    enable = true;
    host = "0.0.0.0";
    acceleration = "rocm";
    rocmOverrideGfx = "11.0.0";
  };
  config.networking.firewall = lib.mkIf config.ollama.enable { allowedTCPPorts = [ 11434 ]; };
  config.environment.persistence."/persist/cache".directories = lib.mkIf config.ollama.enable [
    {
      directory = "/var/lib/private/ollama";
      user = "nouser";
      group = "nogroup";
      mode = "u=rwx,g=,o=";
    }
  ];
}
