From 04cee1bdd89be3692ccbc286b405755c9c6b1bcd Mon Sep 17 00:00:00 2001 From: Chris Thompson Date: Sat, 14 Dec 2024 18:45:21 -0500 Subject: [PATCH] Add ollama service/virtualization block --- hosts/default/configuration.nix | 51 ++++++++++++++++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) diff --git a/hosts/default/configuration.nix b/hosts/default/configuration.nix index aa13c15..1be658d 100644 --- a/hosts/default/configuration.nix +++ b/hosts/default/configuration.nix @@ -275,7 +275,56 @@ hardware.graphics.extraPackages32 = [ pkgs.driversi686Linux.amdvlk ]; - + services.ollama = { + enable = true; + acceleration = "rocm"; + environmentVariables = { + HCC_AMDGPU_TARGET = "gfx1031"; # used to be necessary, but doesn't seem to anymore + }; + rocmOverrideGfx = "10.3.1"; + }; + system.activationScripts = { + script.text = '' + install -d -m 755 /home/wolcen/.open-webui -o root -g root + ''; + }; + virtualisation = { + # Add docker! + docker.enable = true; + podman.enable = false; + docker.storageDriver = "btrfs"; # Only when using BTRFS! (wolcen approved!) + oci-containers = { + backend = "docker"; + containers = { + open-webui = { + image = "ghcr.io/open-webui/open-webui:main"; + + environment = { + "TZ" = "America/New York"; + "OLLAMA_API_BASE_URL" = "http://127.0.0.1:11434/api"; + "OLLAMA_BASE_URL" = "http://127.0.0.1:11434"; + "WEBUI_URL" = "http://127.0.0.1:8080/"; + }; + + volumes = [ + "/home/wolcen/.openweb-ui:/app/backend/data" + ]; + + ports = [ + "127.0.0.1:3000:8080" # Ensures we listen only on localhost + ]; + + extraOptions = [ + "--pull=always" # Pull if the image on the registry is newer + "--name=open-webui" + "--hostname=open-webui" + "--network=host" + "--add-host=host.containers.internal:host-gateway" + ]; + }; + }; + }; + }; # Force radv environment.variables.AMD_VULKAN_ICD = "RADV"; # Or