From 5786863608c72e956949f4bc2a076f39b57d1939 Mon Sep 17 00:00:00 2001 From: atagen Date: Wed, 11 Sep 2024 10:15:54 +1000 Subject: [PATCH] fix llm stuff --- flake.lock | 90 +++++++++++++++++----------------- flake.nix | 3 +- home/bolt.nix | 5 +- home/home.nix | 1 + home/modules/theming.nix | 18 +++---- home/programs/anything-llm.nix | 36 ++++++++------ home/programs/ollama.nix | 17 +++---- home/util/containers.nix | 2 +- home/util/local-webapp.nix | 33 +++++++++---- home/util/name.nix | 17 +++++++ system/configuration.nix | 3 +- system/modules/term.nix | 1 + 12 files changed, 131 insertions(+), 95 deletions(-) create mode 100644 home/util/name.nix diff --git a/flake.lock b/flake.lock index 9785923..9674651 100644 --- a/flake.lock +++ b/flake.lock @@ -238,11 +238,11 @@ "rust-overlay": "rust-overlay" }, "locked": { - "lastModified": 1724856988, - "narHash": "sha256-JBLe2CxAhG+J8+x8qmbzkGHNYmGcSiuY2QO4Zhb72lI=", + "lastModified": 1725976743, + "narHash": "sha256-pLQQbiC9uO4lF58fAnlcDxlbsBB1XFWswsU1oZOIVqU=", "owner": "helix-editor", "repo": "helix", - "rev": "1b5295a3f3d7cccd96eed5bfd394807a4dae87fc", + "rev": "237cbe4bca46eed52efed39ed75eb44aaccbdde3", "type": "github" }, "original": { @@ -258,11 +258,11 @@ ] }, "locked": { - "lastModified": 1724571060, - "narHash": "sha256-2imeYQr9eHrump44kCGdACJXCdjpHgaK9wSsHSl32FQ=", + "lastModified": 1725406787, + "narHash": "sha256-ifkeLCv4vcsDC7MgvGGb++crmUeJ0+QG8L4mg8Bn7GM=", "owner": "n-hass", "repo": "home-manager", - "rev": "87d0708ccc4e4281b8e70b6144cb579228e21154", + "rev": "df5d577ff94303f7f4ffc58e83986274ecec924c", "type": "github" }, "original": { @@ -291,11 +291,11 @@ "lix": { "flake": false, "locked": { - "lastModified": 1725228396, - "narHash": "sha256-QBXwqyPuHUKBiuyzHBxqH/MpjPY9DQiY2M81P2t6b/0=", - "rev": "02eb07cfd539c34c080cb1baf042e5e780c1fcc2", + "lastModified": 1725927421, + "narHash": "sha256-tiQ9OxiuTb/02xEU2ceo9MIxWBS5Rm/IAhv6QshH8K0=", + "rev": "cc183fdbc14ce105a5661d646983f791978b9d5c", "type": "tarball", - "url": "https://git.lix.systems/api/v1/repos/lix-project/lix/archive/02eb07cfd539c34c080cb1baf042e5e780c1fcc2.tar.gz?rev=02eb07cfd539c34c080cb1baf042e5e780c1fcc2" + "url": "https://git.lix.systems/api/v1/repos/lix-project/lix/archive/cc183fdbc14ce105a5661d646983f791978b9d5c.tar.gz?rev=cc183fdbc14ce105a5661d646983f791978b9d5c" }, "original": { "type": "tarball", @@ -314,11 +314,11 @@ ] }, "locked": { - "lastModified": 1723511483, - "narHash": "sha256-rT/OkVXKkns2YvyF1nFvl+8Gc3sld1c1sXPtGkbqaDY=", - "rev": "cecf70b77539c1a593f60ec9d0305b5e537ab6a9", + "lastModified": 1725836728, + "narHash": "sha256-dCbHCwqrzcHlEsRilMX+KM3IfRV46ieGqDyAD3GgCSs=", + "rev": "353b25f0b6da5ede15206d416345a2ec4195b5c8", "type": "tarball", - "url": "https://git.lix.systems/api/v1/repos/lix-project/nixos-module/archive/cecf70b77539c1a593f60ec9d0305b5e537ab6a9.tar.gz?rev=cecf70b77539c1a593f60ec9d0305b5e537ab6a9" + "url": "https://git.lix.systems/api/v1/repos/lix-project/nixos-module/archive/353b25f0b6da5ede15206d416345a2ec4195b5c8.tar.gz?rev=353b25f0b6da5ede15206d416345a2ec4195b5c8" }, "original": { "type": "tarball", @@ -360,8 +360,8 @@ "utils": "utils" }, "locked": { - "lastModified": 1725322213, - "narHash": "sha256-qK1dfFB5i0MpSy4O7M9EcBnMPWqkqoIFbAAwVdYtBfM=", + "lastModified": 1726012053, + "narHash": "sha256-wGfFI8ZD3+TisEW2cFUABbtWYpn0N71CpkiXuITOk88=", "path": "/home/bolt/code/meat", "type": "path" }, @@ -375,11 +375,11 @@ "nixpkgs": "nixpkgs_2" }, "locked": { - "lastModified": 1725287741, - "narHash": "sha256-ZxyB7BwxQjoMz5lUnsb+KuTWfRyPtJVqEjnlOoABSUE=", + "lastModified": 1725746760, + "narHash": "sha256-p38Uini6lChBCF0mZndHXTAy7ZH/OQLY696BFCHg92g=", "owner": "viperML", "repo": "nh", - "rev": "5dd64eb04fddeac2eb08c018212cc58978934920", + "rev": "7650b372e55a36d7765ee0a5e59b142731bc8b3d", "type": "github" }, "original": { @@ -393,11 +393,11 @@ "nixpkgs": "nixpkgs_3" }, "locked": { - "lastModified": 1725161148, - "narHash": "sha256-WfAHq3Ag3vLNFfWxKHjFBFdPI6JIideWFJod9mx1eoo=", + "lastModified": 1725765290, + "narHash": "sha256-hwX53i24KyWzp2nWpQsn8lfGQNCP0JoW/bvQmcR1DPY=", "owner": "Mic92", "repo": "nix-index-database", - "rev": "32058e9138248874773630c846563b1a78ee7a5b", + "rev": "642275444c5a9defce57219c944b3179bf2adaa9", "type": "github" }, "original": { @@ -438,15 +438,15 @@ "treefmt-nix": "treefmt-nix_2" }, "locked": { - "lastModified": 1724271552, - "narHash": "sha256-xn0dC4M3mfItxP+s3/v3Hz/CSKp74VH/gMfufKxl9/4=", - "owner": "Mic92", + "lastModified": 1725635983, + "narHash": "sha256-haSfwdurfltqQ/7YEmDcmWLnWwvAgelIHnXsHG34P1k=", + "owner": "lilyinstarlight", "repo": "nix-update", - "rev": "737121eccb67542e8c004c64da833fede2e80c64", + "rev": "ed54a7546affb3f8c9c3e10a6fa6fdb21756ec8f", "type": "github" }, "original": { - "owner": "Mic92", + "owner": "lilyinstarlight", "repo": "nix-update", "type": "github" } @@ -481,11 +481,11 @@ "rust-overlay": "rust-overlay_2" }, "locked": { - "lastModified": 1725237037, - "narHash": "sha256-rz7xUgTUHKvRsTFQocpespVloYpJ4tIsXmgU1fdXCPw=", + "lastModified": 1726010864, + "narHash": "sha256-bOn5vl87FYeTqR0ymYJxYHFrIdjTSeN3GtqlPlK+2os=", "owner": "lilyinstarlight", "repo": "nixos-cosmic", - "rev": "27ca5fbf0f51d3f02bb0274b0ce9012e5c079fe9", + "rev": "f6c0035d0ab8a689d32128bb10e5c6b9fca78e9d", "type": "github" }, "original": { @@ -561,11 +561,11 @@ }, "nixpkgs-stable_2": { "locked": { - "lastModified": 1725001927, - "narHash": "sha256-eV+63gK0Mp7ygCR0Oy4yIYSNcum2VQwnZamHxYTNi+M=", + "lastModified": 1725826545, + "narHash": "sha256-L64N1rpLlXdc94H+F6scnrbuEu+utC03cDDVvvJGOME=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "6e99f2a27d600612004fbd2c3282d614bfee6421", + "rev": "f4c846aee8e1e29062aa8514d5e0ab270f4ec2f9", "type": "github" }, "original": { @@ -593,11 +593,11 @@ }, "nixpkgs_3": { "locked": { - "lastModified": 1724819573, - "narHash": "sha256-GnR7/ibgIH1vhoy8cYdmXE6iyZqKqFxQSVkFgosBh6w=", + "lastModified": 1725634671, + "narHash": "sha256-v3rIhsJBOMLR8e/RNWxr828tB+WywYIoajrZKFM+0Gg=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "71e91c409d1e654808b2621f28a327acfdad8dc2", + "rev": "574d1eac1c200690e27b8eb4e24887f8df7ac27c", "type": "github" }, "original": { @@ -641,11 +641,11 @@ }, "nixpkgs_6": { "locked": { - "lastModified": 1724819573, - "narHash": "sha256-GnR7/ibgIH1vhoy8cYdmXE6iyZqKqFxQSVkFgosBh6w=", + "lastModified": 1725634671, + "narHash": "sha256-v3rIhsJBOMLR8e/RNWxr828tB+WywYIoajrZKFM+0Gg=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "71e91c409d1e654808b2621f28a327acfdad8dc2", + "rev": "574d1eac1c200690e27b8eb4e24887f8df7ac27c", "type": "github" }, "original": { @@ -657,11 +657,11 @@ }, "nur": { "locked": { - "lastModified": 1725321983, - "narHash": "sha256-k+f0FddjJX4mkEx0he7sLT2yYHv4dVmf63YH6zSbIWo=", + "lastModified": 1726004797, + "narHash": "sha256-EjbaRc4eu8cnR4rF5y6EMWZG8mtJa9BQq4z0hsQMIZg=", "owner": "nix-community", "repo": "NUR", - "rev": "03d44a70b0d8113225a167c9f1751ad5b4c09481", + "rev": "7992767e0d354cfedc418887d4c10aed4515c962", "type": "github" }, "original": { @@ -753,11 +753,11 @@ ] }, "locked": { - "lastModified": 1724984647, - "narHash": "sha256-BC6MUq0CTdmAu/cueVcdWTI+S95s0mJcn19SoEgd7gU=", + "lastModified": 1725848835, + "narHash": "sha256-u4lCr+tOEWhsFiww5G04U5jUNzaQJi0/ZMIDGiLeT14=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "87b6cffc276795b46ef544d7ed8d7fed6ad9c8e4", + "rev": "2ef910a6276a2f34513d18f2f826a8dea72c3b3f", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 486583d..48c4d2c 100644 --- a/flake.nix +++ b/flake.nix @@ -74,7 +74,8 @@ inherit (lib) mapAttrs; sharedModules = [ meat.nixosModules.meat - lix-module.nixosModules.default + # comes with meat + # lix-module.nixosModules.default madness.nixosModules.madness nur.nixosModules.nur nix-index-database.nixosModules.nix-index diff --git a/home/bolt.nix b/home/bolt.nix index 5b55b44..bd8b9c9 100644 --- a/home/bolt.nix +++ b/home/bolt.nix @@ -8,10 +8,7 @@ ./programs/anything-llm.nix ]; - home = { - username = "bolt"; - homeDirectory = "/home/bolt"; - }; + mainUser = "bolt"; home.packages = with pkgs; [ nicotine-plus diff --git a/home/home.nix b/home/home.nix index 604de45..527d707 100644 --- a/home/home.nix +++ b/home/home.nix @@ -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 ]; diff --git a/home/modules/theming.nix b/home/modules/theming.nix index 0deb27d..393159c 100644 --- a/home/modules/theming.nix +++ b/home/modules/theming.nix @@ -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; }; diff --git a/home/programs/anything-llm.nix b/home/programs/anything-llm.nix index 62632d4..fe33dc6 100644 --- a/home/programs/anything-llm.nix +++ b/home/programs/anything-llm.nix @@ -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'") + ]; }; } diff --git a/home/programs/ollama.nix b/home/programs/ollama.nix index 6daa2c6..28fd35d 100644 --- a/home/programs/ollama.nix +++ b/home/programs/ollama.nix @@ -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"]; - # }; } diff --git a/home/util/containers.nix b/home/util/containers.nix index 83dcddd..21ce9f3 100644 --- a/home/util/containers.nix +++ b/home/util/containers.nix @@ -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? diff --git a/home/util/local-webapp.nix b/home/util/local-webapp.nix index b78e5af..fc57250 100644 --- a/home/util/local-webapp.nix +++ b/home/util/local-webapp.nix @@ -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) + '' diff --git a/home/util/name.nix b/home/util/name.nix new file mode 100644 index 0000000..4317b02 --- /dev/null +++ b/home/util/name.nix @@ -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}"; + }; +} diff --git a/system/configuration.nix b/system/configuration.nix index ebce63d..c8522c9 100644 --- a/system/configuration.nix +++ b/system/configuration.nix @@ -11,7 +11,8 @@ inputs.nix-rice.overlays.default inputs.helix.overlays.default inputs.nixd.overlays.default - inputs.nh.overlays.default + # meat overlay includes this + # inputs.nh.overlays.default outputs.overlays.additions outputs.overlays.rice ]; diff --git a/system/modules/term.nix b/system/modules/term.nix index db680e2..59361f7 100644 --- a/system/modules/term.nix +++ b/system/modules/term.nix @@ -2,6 +2,7 @@ murex = pkgs.murex.overrideAttrs { passthru = { shellPath = "/bin/murex"; + overrideModAttrs = {}; }; }; in {