This commit is contained in:
mjallen18
2024-05-31 10:55:22 -05:00
parent 184341c9c1
commit 6d1c6cfc4b
8 changed files with 247 additions and 75 deletions

View File

@@ -0,0 +1,30 @@
{ lib, pkgs, config, ... }:
with lib;
let cfg = config.nas-apps.ollama;
in {
imports = [ ./options.nix ];
config = mkIf cfg.enable {
systemd.services.ollama-docker = {
path = [ pkgs.bash pkgs.docker ];
script = ''
set -e
exec docker run \
--rm \
--gpus all \
--runtime=nvidia \
--name=${cfg.name} \
-e PUID=${cfg.puid} \
-e PGID=${cfg.pgid} \
-e TZ=${cfg.timeZone} \
-e 'NVIDIA_DRIVER_CAPABILITIES'='all' \
-e 'NVIDIA_VISIBLE_DEVICES'='all' \
-p ${cfg.port}:11434 \
-v '${cfg.configPath}:/root/.ollama' \
${cfg.image}:latest
'';
wantedBy = [ "multi-user.target" ];
};
};
}

View File

@@ -0,0 +1,47 @@
{ lib, ... }:
with lib; {
options.nas-apps.ollama = {
enable = mkEnableOption "ollama docker service";
autoStart = mkOption {
type = types.bool;
default = true;
};
port = mkOption {
type = types.str;
default = "11434";
};
name = mkOption {
type = types.str;
default = "ollama";
};
image = mkOption {
type = types.str;
default = "ollama/ollama";
};
configPath = mkOption {
type = types.str;
default = "/mnt/ssd/nix-app-data/ollama";
};
puid = mkOption {
type = types.str;
default = "911";
};
pgid = mkOption {
type = types.str;
default = "1000";
};
timeZone = mkOption {
type = types.str;
default = "America/Chicago";
};
};
}