fix llm stuff

This commit is contained in:
atagen 2024-09-11 10:15:54 +10:00
parent ad421cea84
commit 5786863608
12 changed files with 131 additions and 95 deletions

View file

@ -8,10 +8,7 @@
./programs/anything-llm.nix
];
home = {
username = "bolt";
homeDirectory = "/home/bolt";
};
mainUser = "bolt";
home.packages = with pkgs; [
nicotine-plus

View file

@ -17,6 +17,7 @@ in {
./util/flatpak.nix
./util/cosmic.nix
./util/murex.nix # TODO use these options, write plugin pkgs, etc
./util/name.nix
inputs.nix-index-database.hmModules.nix-index
];

View file

@ -1,13 +1,13 @@
{pkgs, ...}: {
home.packages = with pkgs; [
gtk-engine-murrine
];
# home.packages = with pkgs; [
# gtk-engine-murrine
# ];
fonts.fontconfig.enable = true;
qt = {
enable = true;
style.name = "adwaita-dark";
platformTheme.name = "adwaita";
# style.name = "adwaita-dark";
# platformTheme.name = "adwaita";
};
gtk = with pkgs;
@ -16,10 +16,10 @@
# theme = with gtk-theme; {
# inherit package name;
# };
theme = {
name = "adw-gtk3-dark";
package = adw-gtk3; # cosmic
};
# theme = {
# name = "adw-gtk3-dark";
# package = adw-gtk3; # cosmic
# };
iconTheme = with icons; {
inherit package name;
};

View file

@ -1,6 +1,6 @@
{
lib,
pkgs,
config,
...
}: let
port = 3021;
@ -17,19 +17,25 @@ in {
};
};
services.podman = {
containers.anything-llm = let
str = builtins.toString;
in {
image = "mintplexlabs/anythingllm";
ports = ["${str port}:3001"];
autostart = false;
networks = ["ollama"];
unitConfig = {Requires = ["podman-ollama.service"];};
extraOptions = [
"--health-cmd"
(lib.escapeShellArg "bash -c 'cat < /dev/null > /dev/tcp/localhost/3001'")
];
};
services.podman.containers.anything-llm = let
str = builtins.toString;
username = config.mainUser;
in {
image = "mintplexlabs/anythingllm";
ports = ["${str port}:3001"];
autostart = false;
networks = ["ollama"];
volumes = let
share = "/home/${username}/.local/share/anything-llm";
in [
"${share}:/storage"
"${share}/.env:/app/server/.env"
];
environment.STORAGE_LOCATION = "/storage";
unitConfig = {Requires = ["podman-ollama.service"];};
extraOptions = [
"--health-cmd"
(lib.escapeShellArg "bash -c 'cat < /dev/null > /dev/tcp/localhost/3001'")
];
};
}

View file

@ -1,19 +1,24 @@
{
lib,
pkgs,
config,
...
}: {
services.podman = {
containers.ollama = {
containers.ollama = let
username = config.mainUser;
in {
image = "ollama/ollama:latest";
devices = ["nvidia.com/gpu=all"];
autostart = false;
networks = ["ollama"];
volumes = [
"/home/${username}/.local/share/ollama:/models"
];
environment.OLLAMA_MODELS = "/models";
extraOptions = [
"--health-cmd"
(lib.escapeShellArg "bash -c 'cat < /dev/null > /dev/tcp/localhost/11434'")
];
# TODO make a volume lol
};
networks.ollama = {
@ -21,10 +26,4 @@
Gateway = "192.168.10.1";
};
};
# containers.ollama = {
# image = "ollama/ollama:latest";
# # TODO: volume for models!
# extraOptions = ["--network=host" "--device=nvidia.com/gpu=all"];
# };
}

View file

@ -303,7 +303,7 @@
++ map escapeShellArg container.cmd
);
inherit (lib) concatStringsSep escapeShellArg optional optionalAttrs optionalString mapAttrsToList;
inherit (lib) concatStringsSep escapeShellArg optional mapAttrsToList;
in {
Unit = {
WantedBy = [] ++ lib.optional (container.autoStart) "default.target"; # graphical-session instead maybe?

View file

@ -4,9 +4,22 @@
lib,
...
}: let
inherit (lib) mkOption;
inherit (lib.attrsets) mapAttrs mapAttrs' nameValuePair;
inherit (lib) getExe getExe';
inherit
(lib)
mkOption
mkForce
getExe
getExe'
listToAttrs
flatten
mapAttrsToList
mapAttrs
mapAttrs'
nameValuePair
toLower
replaceStrings
concatMapStringsSep
;
# make a firefox webapp + hidden .desktop entry for the client app
make-firefox = cfg:
mapAttrs' (
@ -31,7 +44,7 @@
nameValuePair "${cfg.name}-frontend" {
Unit = {
Description = "${cfg.name} Frontend";
WantedBy = lib.mkForce [];
WantedBy = mkForce [];
};
Service = cfg.service;
@ -41,13 +54,13 @@
cfg;
# modify systemd units to be PartOf this target
modify-systemd-services = cfg:
lib.listToAttrs (lib.flatten (lib.mapAttrsToList (
listToAttrs (flatten (mapAttrsToList (
name: cfg: (map (
req: {
name = "${req}";
value = {
Unit = {
PartOf = "${lib.toLower cfg.name}.target";
PartOf = "${replaceStrings [" "] ["-"] (toLower cfg.name)}.target";
};
};
}
@ -56,13 +69,13 @@
)
cfg));
modify-quadlets = cfg:
lib.listToAttrs (lib.flatten (lib.mapAttrsToList (
listToAttrs (flatten (mapAttrsToList (
name: cfg: (map (
req: {
name = "${req}";
value = {
unitConfig = {
PartOf = "${lib.toLower cfg.name}.target";
PartOf = "${toLower cfg.name}.target";
};
};
}
@ -76,7 +89,7 @@
name: cfg: {
Unit = {
Description = "${cfg.name} Target";
WantedBy = lib.mkForce [];
WantedBy = mkForce [];
Requires =
(map (req: req + ".service") cfg.requires.services)
++ (map (req: "podman-" + req + ".service") cfg.requires.containers);
@ -105,7 +118,7 @@
''
container_checks() {
if ''
+ (lib.concatMapStringsSep " && "
+ (concatMapStringsSep " && "
(container: makeContainerCheck container)
cfg.requires.containers)
+ ''

17
home/util/name.nix Normal file
View file

@ -0,0 +1,17 @@
{
lib,
config,
...
}: let
inherit (lib) mkOption;
in {
options.mainUser = mkOption {
type = lib.types.str;
};
config.home = let
inherit (config) mainUser;
in {
username = mainUser;
homeDirectory = "/home/${mainUser}";
};
}