fix(ollama): Broken dataDir convention; Allow ENVs in dataDir

Easy to break the convention, see:
https://github.com/juspay/services-flake/issues/200

double-quotting in shell script prevents globbing:
https://www.shellcheck.net/wiki/SC2086
This commit is contained in:
shivaraj-bh 2024-06-14 02:57:57 +05:30 committed by Shivaraj B H
parent e7eb9dec41
commit db7ab711d9

View File

@ -30,7 +30,7 @@ in
};
dataDir = lib.mkOption {
type = types.str;
default = "./data/ollama";
default = "./data/${name}";
description = ''
The directory containing the Ollama models.
Sets the `OLLAMA_MODELS` environment variable.
@ -93,9 +93,9 @@ in
startScript = pkgs.writeShellApplication {
name = "ollama-server";
text = ''
if [ ! -d ${config.dataDir} ]; then
if [ ! -d "${config.dataDir}" ]; then
echo "Creating directory ${config.dataDir}"
mkdir -p ${config.dataDir}
mkdir -p "${config.dataDir}"
fi
${lib.getExe config.package} serve