From 210816195b5d999d6cdbc53c20a9c1ba1d482f2f Mon Sep 17 00:00:00 2001 From: Raphael Date: Thu, 3 Jul 2025 23:22:54 +0200 Subject: [PATCH] feat(self/ollama): Mistral 7b setup with ollama --- hosts/global.nix | 2 +- hosts/server/configuration.nix | 1 + services/self_host.nix | 9 +++++++++ services/self_host/monitor.nix | 1 + services/self_host/ollama.nix | 29 +++++++++++++++++++++++++++++ 5 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 services/self_host/ollama.nix diff --git a/hosts/global.nix b/hosts/global.nix index e2074bf..52ecf8c 100644 --- a/hosts/global.nix +++ b/hosts/global.nix @@ -50,7 +50,7 @@ nixpkgs.config.allowUnfree = true; nix.settings = { - download-buffer-size = 16777216; + download-buffer-size = 1048576; experimental-features = [ "nix-command" "flakes" diff --git a/hosts/server/configuration.nix b/hosts/server/configuration.nix index 0ef987d..b41daf3 100644 --- a/hosts/server/configuration.nix +++ b/hosts/server/configuration.nix @@ -22,6 +22,7 @@ service = { selfhost = { htop = true; + ollama = true; monitor = true; nextcloud = true; }; diff --git a/services/self_host.nix b/services/self_host.nix index 887793b..37fbbc5 100644 --- a/services/self_host.nix +++ b/services/self_host.nix @@ -7,6 +7,9 @@ let monitor = import ./self_host/monitor.nix { inherit inputs config pkgs lib; }; + ollama = import ./self_host/ollama.nix { + inherit inputs config pkgs lib; + }; nextcloud = import ./self_host/nextcloud.nix { inherit inputs config pkgs lib; }; @@ -16,6 +19,7 @@ in imports = [ nextcloud htop + ollama monitor ]; @@ -30,6 +34,11 @@ in default = false; description = "Enable the htop"; }; + ollama = lib.mkOption { + type = lib.types.bool; + default = false; + description = "Enable the ollama"; + }; monitor = lib.mkOption { type = lib.types.bool; default = false; diff --git a/services/self_host/monitor.nix b/services/self_host/monitor.nix index 42da369..bf034b6 100644 --- a/services/self_host/monitor.nix +++ b/services/self_host/monitor.nix @@ -95,6 +95,7 @@ in "https://nextcloud.enium.eu" "https://htop.enium.eu" "https://monitor.enium.eu" + "https://ollama.enium.eu" "http://relance-pas-stp.me:4242" ]; }]; diff --git a/services/self_host/ollama.nix b/services/self_host/ollama.nix new file mode 100644 index 0000000..f3f9f4d --- /dev/null +++ b/services/self_host/ollama.nix @@ -0,0 +1,29 @@ +{ config, pkgs, lib, ... }: + +let + cfg = config.service.selfhost.ollama; +in +{ + services = { + ollama = { + enable = true; + loadModels = [ + "mistral:7b" + ]; + acceleration = "cuda"; + }; + + open-webui = { + enable = true; + port = 13007; + }; + nginx.virtualHosts."ollama.enium.eu" = { + enableACME = true; + forceSSL = true; + locations."/" = { + proxyPass = "http://127.0.0.1:13007"; + proxyWebsockets = true; + }; + }; + }; +}