49 lines
1.4 KiB
Nix
49 lines
1.4 KiB
Nix
{
|
|
config,
|
|
lib,
|
|
...
|
|
}: {
|
|
options = {
|
|
services.ollama.impermanence.enable = lib.mkOption {
|
|
type = lib.types.bool;
|
|
default = config.services.ollama.enable && config.storage.impermanence.enable;
|
|
};
|
|
};
|
|
|
|
config = lib.mkIf config.services.ollama.enable (
|
|
lib.mkMerge [
|
|
(lib.mkIf config.storage.zfs.enable (lib.mkMerge [
|
|
{
|
|
# Ollama needs persistent storage for models and configuration
|
|
}
|
|
(lib.mkIf (!config.services.ollama.impermanence.enable) {
|
|
# TODO: placeholder to configure a unique dataset for this service
|
|
})
|
|
(lib.mkIf config.services.ollama.impermanence.enable {
|
|
storage.impermanence.datasets."persist/replicate/system/root" = {
|
|
directories."/var/lib/private/ollama" = {
|
|
enable = true;
|
|
owner.name = config.services.ollama.user;
|
|
group.name = config.services.ollama.group;
|
|
owner.permissions = {
|
|
read = true;
|
|
write = true;
|
|
execute = false;
|
|
};
|
|
group.permissions = {
|
|
read = false;
|
|
write = false;
|
|
execute = false;
|
|
};
|
|
other.permissions = {
|
|
read = false;
|
|
write = false;
|
|
execute = false;
|
|
};
|
|
};
|
|
};
|
|
})
|
|
]))
|
|
]
|
|
);
|
|
}
|