snowfall lib migration wip

This commit is contained in:
Aleksandr Lebedev 2025-08-07 18:07:27 +02:00
parent b9dadac2af
commit ed08a98651
31 changed files with 1067 additions and 172 deletions

View file

@ -0,0 +1,72 @@
{
lib,
pkgs,
inputs,
namespace,
system,
target,
format,
virtual,
systems,
config,
...
}:
with lib;
with lib.${namespace}; let
cfg = config.${namespace}.services.ai;
impermanence = config.${namespace}.impermanence;
nvidia = config.${namespace}.hardware.nvidia;
persist = impermanence.persistentStorage;
in {
options.${namespace}.services.ai = with types; {
enable = mkBoolOpt false "Enable local ai powered by ollama";
models = lib.mkOption {
type = types.listOf types.str;
default = [];
description = ''
Download these models using `ollama pull` as soon as `ollama.service` has started.
This creates a systemd unit `ollama-model-loader.service`.
Search for models of your choice from: <https://ollama.com/library>
'';
};
ui.enable = mkBoolOpt true "Enable openwebui at localhost:8080";
ui.port = mkOption {
type = types.port;
default = 8080;
description = ''
Port for ui
'';
};
};
config = mkIf cfg.enable {
services.ollama = {
enable = true;
loadModels = cfg.models;
acceleration =
if nvidia.enable
then "cuda"
else null;
home =
if impermanence.enable
then "${persist}/ollama"
else "/var/lib/ollama";
user = "ollama";
group = "ollama";
};
services.open-webui.enable = cfg.ui.enable;
services.open-webui.openFirewall = false;
services.open-webui.host = "0.0.0.0";
services.open-webui.port = cfg.ui.port;
services.open-webui.stateDir =
if impermanence.enable
then "${persist}/open-webui"
else "/var/lib/open-webui";
systemd.services.open-webui.serviceConfig.User = "ollama";
systemd.services.open-webui.serviceConfig.Group = "ollama";
systemd.services.open-webui.serviceConfig.DynamicUser = lib.mkForce false;
};
}

View file

@ -19,22 +19,24 @@ in {
options.${namespace}.services.syncthing = with types; {
enable = mkBoolOpt false "Enable syncthing service for the user";
user = lib.mkOption {
type = lib.types.singleLineStr;
default = "";
example = "nixos";
description = ''
User, that will use the syncthing service (only one at a time)
'';
};
type = lib.types.singleLineStr;
default = "";
example = "nixos";
description = ''
User, that will use the syncthing service (only one at a time)
'';
};
};
config =
mkIf cfg.enable {
systemd.services.syncthing.environment.STNODEFAULTFOLDER = "true"; # Don't create default ~/Sync folder
services.syncthing = {
inherit (cfg) user;
configDir = optional (impermanence.enable) "${impermanence.persistentStorage}/home/${cfg.user}/.config/syncthing";
enable = true;
};
config = mkIf cfg.enable {
systemd.services.syncthing.environment.STNODEFAULTFOLDER = "true"; # Don't create default ~/Sync folder
services.syncthing = {
inherit (cfg) user;
configDir =
if impermanence.enable
then "${impermanence.persistentStorage}/home/${cfg.user}/.config/syncthing"
else "/home/${cfg.user}/.config.syncthing";
enable = true;
};
};
}