From b010d90306f53340cfeb91ae12a84f7336224639 Mon Sep 17 00:00:00 2001 From: Ohad Livne Date: Wed, 12 Nov 2025 11:39:46 +0200 Subject: [PATCH 01/11] Use MPV as the default player for OGG/Opus audio files --- .config/mimeapps.list | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.config/mimeapps.list b/.config/mimeapps.list index ff1ce92..ddbdff7 100644 --- a/.config/mimeapps.list +++ b/.config/mimeapps.list @@ -10,6 +10,8 @@ application/xhtml+xml=userapp-Firefox-RJEWT1.desktop application/x-extension-xhtml=userapp-Firefox-RJEWT1.desktop application/x-extension-xht=userapp-Firefox-RJEWT1.desktop x-scheme-handler/magnet=userapp-transmission-gtk-BAUQU2.desktop +audio/ogg=mpv.desktop; +audio/x-opus+ogg=mpv.desktop; [Added Associations] x-scheme-handler/http=userapp-Firefox-RJEWT1.desktop; From 40f24304eafc8dfee0130f03c8e5eeabb0dc81ee Mon Sep 17 00:00:00 2001 From: Ohad Livne Date: Wed, 12 Nov 2025 11:42:22 +0200 Subject: [PATCH 02/11] Declare a quadlet file for an Ollama server --- .config/containers/systemd/ollama.container | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 .config/containers/systemd/ollama.container diff --git a/.config/containers/systemd/ollama.container b/.config/containers/systemd/ollama.container new file mode 100644 index 0000000..a9082b9 --- /dev/null +++ b/.config/containers/systemd/ollama.container @@ -0,0 +1,13 @@ +[Unit] +Description=A local LLM server + +[Container] +ContainerName=ollama +Image=docker.io/ollama/ollama:latest +PublishPort=11434:11434 + +[Install] +WantedBy=multi-user.target + +[Service] +Restart=always From 9147292b66d00ebef9a479c2ae982736c68f5bd5 Mon Sep 17 00:00:00 2001 From: Ohad Livne Date: Wed, 12 Nov 2025 11:47:40 +0200 Subject: [PATCH 03/11] Synchronize branch and tag metadata by default --- .config/emacs/transient/values.el | 1 + 1 file changed, 1 insertion(+) diff --git a/.config/emacs/transient/values.el b/.config/emacs/transient/values.el index c77d63e..e9662fa 100644 --- a/.config/emacs/transient/values.el +++ b/.config/emacs/transient/values.el @@ -2,6 +2,7 @@ ; keep-sorted start (magit-commit "--gpg-sign=") (magit-diff:magit-revision-mode "--no-ext-diff" "--stat" "--show-signature") + (magit-fetch "--force" "--prune" "--tags") (magit-log:magit-log-mode "-n256" "--graph" "--decorate" "--show-signature") (magit-merge "--gpg-sign=") (magit-tag "--sign") From 98dc827a10d5bd06e84f4a2caecc66bb03c9a8cc Mon Sep 17 00:00:00 2001 From: Ohad Livne Date: Wed, 12 Nov 2025 11:48:08 +0200 Subject: [PATCH 04/11] Wrap long lines in chat interaction for convenience --- .config/emacs/init.el | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.config/emacs/init.el b/.config/emacs/init.el index 0be5a4f..1b015b7 100644 --- a/.config/emacs/init.el +++ b/.config/emacs/init.el @@ -307,6 +307,8 @@ ) (use-package gptel + :hook + (gptel-mode . visual-line-mode) :custom ; keep-sorted start (gptel-backend (gptel-get-backend "Claude")) From be95a1eb42bb88303666340f09ce5d36844072c1 Mon Sep 17 00:00:00 2001 From: Ohad Livne Date: Wed, 12 Nov 2025 11:48:32 +0200 Subject: [PATCH 05/11] Allow gptel to use the Ollama server --- .config/emacs/init.el | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.config/emacs/init.el b/.config/emacs/init.el index 1b015b7..9459afa 100644 --- a/.config/emacs/init.el +++ b/.config/emacs/init.el @@ -320,6 +320,10 @@ :stream t :key 'gptel-api-key-from-auth-source ) + (gptel-make-ollama "Ollama" + :stream t + :models '(llama3.2:latest) + ) ) (use-package power-mode) From 304710810c8aaec51f3ccb3073742145cbb45cbe Mon Sep 17 00:00:00 2001 From: Ohad Livne Date: Wed, 12 Nov 2025 11:48:48 +0200 Subject: [PATCH 06/11] Make Ollama the default backend for gptel --- .config/emacs/init.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.config/emacs/init.el b/.config/emacs/init.el index 9459afa..92c6b6d 100644 --- a/.config/emacs/init.el +++ b/.config/emacs/init.el @@ -311,9 +311,9 @@ (gptel-mode . visual-line-mode) :custom ; keep-sorted start - (gptel-backend (gptel-get-backend "Claude")) + (gptel-backend (gptel-get-backend "Ollama")) (gptel-default-mode 'org-mode) - (gptel-model 'claude-3-5-haiku-20241022) + (gptel-model 'llama3.2:latest) ; keep-sorted end :preface (gptel-make-anthropic "Claude" From bd5cfa7a65d8a21b8b2b02ef17365cde9b763a8e Mon Sep 17 00:00:00 2001 From: Ohad Livne Date: Wed, 12 Nov 2025 17:30:15 +0200 Subject: [PATCH 07/11] Personalize chat UX more --- .config/emacs/init.el | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.config/emacs/init.el b/.config/emacs/init.el index 92c6b6d..e3a988b 100644 --- a/.config/emacs/init.el +++ b/.config/emacs/init.el @@ -308,11 +308,17 @@ (use-package gptel :hook + ; keep-sorted start + (gptel-mode . gptel-highlight-mode) (gptel-mode . visual-line-mode) + (gptel-post-response . gptel-end-of-response) + (gptel-post-stream . gptel-auto-scroll) + ; keep-sorted end :custom ; keep-sorted start (gptel-backend (gptel-get-backend "Ollama")) (gptel-default-mode 'org-mode) + (gptel-highlight-methods '(face margin)) (gptel-model 'llama3.2:latest) ; keep-sorted end :preface From 8a29d8da404752143560d96b28bde3138de7ad55 Mon Sep 17 00:00:00 2001 From: Ohad Livne Date: Wed, 12 Nov 2025 17:45:04 +0200 Subject: [PATCH 08/11] Keep the models in a persistent volume --- .config/containers/systemd/ollama.container | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.config/containers/systemd/ollama.container b/.config/containers/systemd/ollama.container index a9082b9..4c6b9e9 100644 --- a/.config/containers/systemd/ollama.container +++ b/.config/containers/systemd/ollama.container @@ -2,12 +2,18 @@ Description=A local LLM server [Container] +# keep-sorted start ContainerName=ollama Image=docker.io/ollama/ollama:latest PublishPort=11434:11434 +Volume=%h/.local/share/ollama:/root/.ollama:Z +# keep-sorted end [Install] WantedBy=multi-user.target [Service] +# keep-sorted start +ExecStartPre=mkdir -p %h/.local/share/ollama Restart=always +# keep-sorted end From 02a366a78254f1f3d6797f1e0a559d2dcdd4e277 Mon Sep 17 00:00:00 2001 From: Ohad Livne Date: Wed, 12 Nov 2025 20:43:19 +0200 Subject: [PATCH 09/11] Create a dedicated script to import new models --- .local/bin/llm-import-model | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100755 .local/bin/llm-import-model diff --git a/.local/bin/llm-import-model b/.local/bin/llm-import-model new file mode 100755 index 0000000..ffd2c6c --- /dev/null +++ b/.local/bin/llm-import-model @@ -0,0 +1,9 @@ +#! /usr/bin/bash + +set -euo pipefail +IFS=$'\n\t' + +mkdir --parents ~/.local/share/ollama/ +pod_id=$(podman run --detach --rm --volume ~/.local/share/ollama/:/root/.ollama ollama:latest) +podman exec --interactive --tty "${pod_id}" ollama pull "${1}" +podman kill "${pod_id}" From 8d131ea8beb423cbb14cfde75cfae53d3a50d221 Mon Sep 17 00:00:00 2001 From: Ohad Livne Date: Wed, 12 Nov 2025 20:43:55 +0200 Subject: [PATCH 10/11] Revoke unnecessary filesystem permissions for the server --- .config/containers/systemd/ollama.container | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.config/containers/systemd/ollama.container b/.config/containers/systemd/ollama.container index 4c6b9e9..fc91619 100644 --- a/.config/containers/systemd/ollama.container +++ b/.config/containers/systemd/ollama.container @@ -6,7 +6,7 @@ Description=A local LLM server ContainerName=ollama Image=docker.io/ollama/ollama:latest PublishPort=11434:11434 -Volume=%h/.local/share/ollama:/root/.ollama:Z +Volume=%h/.local/share/ollama:/root/.ollama:ro,z # keep-sorted end [Install] From 04d9cc5eed7bbe792ae5b92fd6824bb3eb5ce1fb Mon Sep 17 00:00:00 2001 From: Ohad Livne Date: Wed, 12 Nov 2025 21:00:27 +0200 Subject: [PATCH 11/11] Isolate the LLM server from the internet --- .config/containers/systemd/ollama.container | 1 + .config/containers/systemd/ollama.network | 5 +++++ 2 files changed, 6 insertions(+) create mode 100644 .config/containers/systemd/ollama.network diff --git a/.config/containers/systemd/ollama.container b/.config/containers/systemd/ollama.container index fc91619..6ae7f6c 100644 --- a/.config/containers/systemd/ollama.container +++ b/.config/containers/systemd/ollama.container @@ -5,6 +5,7 @@ Description=A local LLM server # keep-sorted start ContainerName=ollama Image=docker.io/ollama/ollama:latest +Network=ollama.network PublishPort=11434:11434 Volume=%h/.local/share/ollama:/root/.ollama:ro,z # keep-sorted end diff --git a/.config/containers/systemd/ollama.network b/.config/containers/systemd/ollama.network new file mode 100644 index 0000000..5f8c30b --- /dev/null +++ b/.config/containers/systemd/ollama.network @@ -0,0 +1,5 @@ +[Unit] +Description=Isolated network for my local LLM server + +[Network] +Internal=true