diff options
| author | Vineet Kumar <git@vineetk.net> | 2026-04-27 11:37:12 -0400 |
|---|---|---|
| committer | Vineet Kumar <git@vineetk.net> | 2026-04-27 11:37:12 -0400 |
| commit | 38d29789c4d01a7921952f09ef54f2875308d46c (patch) | |
| tree | da94d323f3cc75923cefe1ba52dc36b9a1aeb099 | |
| parent | 24e471ddc7b5367e7cdcd1bcbd70c45a812a3131 (diff) | |
services/machine-learning: drop privileges for llama-swap service
| -rw-r--r-- | epistemia/services/machine-learning.scm | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/epistemia/services/machine-learning.scm b/epistemia/services/machine-learning.scm index 0226300..3d94908 100644 --- a/epistemia/services/machine-learning.scm +++ b/epistemia/services/machine-learning.scm | |||
| @@ -1,6 +1,8 @@ | |||
| 1 | (define-module (epistemia services machine-learning) | 1 | (define-module (epistemia services machine-learning) |
| 2 | #:use-module (gnu packages admin) | ||
| 2 | #:use-module (gnu services) | 3 | #:use-module (gnu services) |
| 3 | #:use-module (gnu services shepherd) | 4 | #:use-module (gnu services shepherd) |
| 5 | #:use-module (gnu system shadow) | ||
| 4 | #:use-module (guix gexp) | 6 | #:use-module (guix gexp) |
| 5 | #:use-module (guix records) | 7 | #:use-module (guix records) |
| 6 | #:export (llama-swap-configuration | 8 | #:export (llama-swap-configuration |
| @@ -20,6 +22,15 @@ | |||
| 20 | (watch-config? llama-swap-configuration-watch-config? | 22 | (watch-config? llama-swap-configuration-watch-config? |
| 21 | (default #f))) | 23 | (default #f))) |
| 22 | 24 | ||
| 25 | (define llama-swap-account-service | ||
| 26 | (list (user-account | ||
| 27 | (name "llama-swap") | ||
| 28 | (group "nogroup") | ||
| 29 | (system? #t) | ||
| 30 | (comment "llama-swap daemon user") | ||
| 31 | (home-directory "/var/empty") | ||
| 32 | (shell (file-append shadow "/sbin/nologin"))))) | ||
| 33 | |||
| 23 | (define (llama-swap-shepherd-service config) | 34 | (define (llama-swap-shepherd-service config) |
| 24 | (let ((pkg (llama-swap-configuration-package config)) | 35 | (let ((pkg (llama-swap-configuration-package config)) |
| 25 | (lcpp (llama-swap-configuration-llama-cpp config)) | 36 | (lcpp (llama-swap-configuration-llama-cpp config)) |
| @@ -37,18 +48,20 @@ | |||
| 37 | "-config" #$cfg | 48 | "-config" #$cfg |
| 38 | "-listen" #$listen) | 49 | "-listen" #$listen) |
| 39 | (if #$watch? '("-watch-config") '())) | 50 | (if #$watch? '("-watch-config") '())) |
| 51 | #:user "llama-swap" | ||
| 40 | #:environment-variables | 52 | #:environment-variables |
| 41 | (cons (string-append "PATH=" #$(file-append lcpp "/bin")) | 53 | (cons (string-append "PATH=" #$(file-append lcpp "/bin")) |
| 42 | (default-environment-variables)))) | 54 | (default-environment-variables)))) |
| 43 | (stop #~(make-kill-destructor)))))) | 55 | (stop #~(make-kill-destructor)))))) |
| 44 | 56 | ||
| 45 | (define llama-swap-service-type | 57 | (define llama-swap-service-type |
| 46 | (service-type | 58 | (service-type (name 'llama-swap) |
| 47 | (name 'llama-swap) | 59 | (extensions |
| 48 | (extensions | 60 | (list (service-extension account-service-type |
| 49 | (list (service-extension shepherd-root-service-type | 61 | (const llama-swap-account-service)) |
| 50 | llama-swap-shepherd-service))) | 62 | (service-extension shepherd-root-service-type |
| 51 | (description | 63 | llama-swap-shepherd-service))) |
| 52 | "llama-swap is an @code{OpenAI} API compatible server that gives you complete | 64 | (description |
| 65 | "llama-swap is an @code{OpenAI} API compatible server that gives you complete | ||
| 53 | control over how you use your hardware. It automatically swaps to the | 66 | control over how you use your hardware. It automatically swaps to the |
| 54 | configuration of your choice for serving a model."))) | 67 | configuration of your choice for serving a model."))) |
