From 4f1b74b41b907a1621e4be6c739814a5d495daad Mon Sep 17 00:00:00 2001 From: Nathan Date: Tue, 29 Jul 2025 17:56:36 -0500 Subject: [PATCH] ollama container? --- .../configuration/homebox/default.nix | 2 +- system-config/services/containers/default.nix | 1 + .../services/containers/n8n/default.nix | 8 +- .../services/containers/ollama/default.nix | 88 +++++++++++++++++++ 4 files changed, 96 insertions(+), 3 deletions(-) create mode 100644 system-config/services/containers/ollama/default.nix diff --git a/system-config/configuration/homebox/default.nix b/system-config/configuration/homebox/default.nix index 3caed72..22dc2db 100644 --- a/system-config/configuration/homebox/default.nix +++ b/system-config/configuration/homebox/default.nix @@ -260,13 +260,13 @@ "blunkall.us".enable = true; pihole.enable = false; #broken nextcloud.enable = true; - #gitlab.enable = false; #gitea is better gitea.enable = true; homeassistant.enable = false; ntfy.enable = false; netbird.enable = true; rustdesk.enable = false; #broken keycloak.enable = true; + ollama.enable = true; }; }; }; diff --git a/system-config/services/containers/default.nix b/system-config/services/containers/default.nix index 68677d7..78e8f74 100644 --- a/system-config/services/containers/default.nix +++ b/system-config/services/containers/default.nix @@ -13,5 +13,6 @@ ./rustdesk ./netbird ./keycloak + ./ollama ]; } diff --git a/system-config/services/containers/n8n/default.nix b/system-config/services/containers/n8n/default.nix index 8da9502..1ff4056 100644 --- a/system-config/services/containers/n8n/default.nix +++ b/system-config/services/containers/n8n/default.nix @@ -16,10 +16,14 @@ config = { - networking.firewall.allowedTCPPorts = [ 80 ]; - services.n8n = { + enable = true; + openFirewall = true; + + settings = {}; + + webhookUrl = ""; }; system.stateVersion = "25.05"; diff --git a/system-config/services/containers/ollama/default.nix b/system-config/services/containers/ollama/default.nix new file mode 100644 index 0000000..857a28d --- /dev/null +++ b/system-config/services/containers/ollama/default.nix @@ -0,0 +1,88 @@ +{ config, lib, inputs, ... }: { + + options = { + sysconfig.opts.virtualization.ollama.enable = lib.options.mkOption { + type = lib.types.bool; + default = false; + }; + }; + + config = lib.mkIf config.sysconfig.opts.virtualization.ollama.enable { + + containers.ollama = { + + autoStart = true; + privateNetwork = true; + hostAddress = "192.168.100.10"; + localAddress = "192.168.100.24"; + + bindMounts = { + "/dev/nvidia0" = { + hostPath = "/dev/nvidia0"; + isReadOnly = false; + }; + "/dev/nvidiactl" = { + hostPath = "/dev/nvidiactl"; + isReadOnly = false; + }; + "/dev/nvidia-uvm" = { + hostPath = "/dev/nvidia-uvm"; + isReadOnly = false; + }; + "/dev/nvidia-modeset" = { + hostPath = "/dev/nvidia-modeset"; + isReadOnly = false; + }; + "/dev/nvidia-uvm-tools" = { + hostPath = "/dev/nvidia-uvm-tools"; + isReadOnly = false; + }; + }; + + allowedDevices = { + nvidia0 = { + node = "/dev/nvidia0"; + modifier = "rw"; + }; + nvidiactl = { + node = "/dev/nvidiactl"; + modifier = "rw"; + }; + nvidia-uvm = { + node = "/dev/nvidia-uvm"; + modifier = "rw"; + }; + nvidia-modeset = { + node = "/dev/nvidia-modeset"; + modifier = "rw"; + }; + nvidia-uvm-tools = { + node = "/dev/nvidia-uvm-tools"; + modifier = "rw"; + }; + }; + + config = { + + services.ollama = { + enable = true; + acceleration = "cuda"; + package = let + pkgs-us = import inputs.nixpkgs-us { + system = "x86_64-linux"; + config.allowUnfree = true; + }; + in pkgs-us.ollama; + + host = "0.0.0.0"; + port = 80; + + openFirewall = true; + }; + + system.stateVersion = "25.05"; + }; + }; + + }; +}