8 cfg = config.services.nextjs-ollama-llm-ui;
9 # we have to override the URL to a Ollama service here, because it gets baked into the web app.
10 nextjs-ollama-llm-ui = cfg.package.override { inherit (cfg) ollamaUrl; };
14 services.nextjs-ollama-llm-ui = {
15 enable = lib.mkEnableOption ''
16 Simple Ollama web UI service; an easy to use web frontend for a Ollama backend service.
17 Run state-of-the-art AI large language models (LLM) similar to ChatGPT locally with privacy
18 on your personal computer.
19 This service is stateless and doesn't store any data on the server; all data is kept
20 locally in your web browser.
21 See https://github.com/jakobhoeg/nextjs-ollama-llm-ui.
23 Required: You need the Ollama backend service running by having
24 "services.nextjs-ollama-llm-ui.ollamaUrl" point to the correct url.
25 You can host such a backend service with NixOS through "services.ollama".
27 package = lib.mkPackageOption pkgs "nextjs-ollama-llm-ui" { };
29 hostname = lib.mkOption {
31 default = "127.0.0.1";
32 example = "ui.example.org";
34 The hostname under which the Ollama UI interface should be accessible.
35 By default it uses localhost/127.0.0.1 to be accessible only from the local machine.
36 Change to "0.0.0.0" to make it directly accessible from the local network.
38 Note: You should keep it at 127.0.0.1 and only serve to the local
39 network or internet from a (home) server behind a reverse-proxy and secured encryption.
40 See https://wiki.nixos.org/wiki/Nginx for instructions on how to set up a reverse-proxy.
45 type = lib.types.port;
49 The port under which the Ollama UI interface should be accessible.
53 ollamaUrl = lib.mkOption {
55 default = "127.0.0.1:11434";
56 example = "https://ollama.example.org";
58 The address (including host and port) under which we can access the Ollama backend server.
59 !Note that if the the UI service is running under a domain "https://ui.example.org",
60 the Ollama backend service must allow "CORS" requests from this domain, e.g. by adding
61 "services.ollama.environment.OLLAMA_ORIGINS = [ ... "https://ui.example.org" ];"!
67 config = lib.mkIf cfg.enable {
70 nextjs-ollama-llm-ui = {
71 wantedBy = [ "multi-user.target" ];
72 description = "Nextjs Ollama LLM Ui.";
73 after = [ "network.target" ];
75 HOSTNAME = cfg.hostname;
76 PORT = toString cfg.port;
77 NEXT_PUBLIC_OLLAMA_URL = cfg.ollamaUrl;
80 ExecStart = "${lib.getExe nextjs-ollama-llm-ui}";
86 meta.maintainers = with lib.maintainers; [ malteneuss ];