diff --git a/flake.nix b/flake.nix index fc51ced8..f3dfd552 100644 --- a/flake.nix +++ b/flake.nix @@ -109,6 +109,7 @@ pkgs = self.packages.${sys}; specialArgs = { flake = self; machine-name = name; }; modules = [ + ./hosts/modules/servers/infinity.nix ./hosts/${name}/configuration.nix self.inputs.agenix.nixosModules.default { programs.ssh.setXAuthLocation = lib.mkForce true; } diff --git a/hosts/common_darwin.nix b/hosts/common_darwin.nix index 1a1e1c03..d4157929 100644 --- a/hosts/common_darwin.nix +++ b/hosts/common_darwin.nix @@ -106,6 +106,7 @@ in util = [ "dbeaver-community" "docker" + "ghostty" "insomnia" "karabiner-elements" "keybase" diff --git a/hosts/modules/darwin/infinity.nix b/hosts/modules/darwin/infinity.nix index ba17e46c..d9376358 100644 --- a/hosts/modules/darwin/infinity.nix +++ b/hosts/modules/darwin/infinity.nix @@ -29,10 +29,11 @@ in models = mkOption { type = types.listOf types.str; default = [ - "BAAI/bge-small-en-v1.5" + "nomic-ai/nomic-embed-text-v1.5" # check out the MTEB leaderboard! ### https://huggingface.co/spaces/mteb/leaderboard # "jinaai/jina-embeddings-v3" + # "BAAI/bge-small-en-v1.5" # "dunzhang/stella_en_400M_v5" # requires xformers? ]; description = "the list of embeddings models to load"; diff --git a/hosts/modules/games/palworld.nix b/hosts/modules/games/palworld.nix index 55e6322e..0cfec617 100644 --- a/hosts/modules/games/palworld.nix +++ b/hosts/modules/games/palworld.nix @@ -1,7 +1,7 @@ { config, pkgs, lib, ... }: let inherit (lib) mkIf mkEnableOption mkOption; - inherit (lib.types) path port str number; + inherit (lib.types) nullOr path port str number; cfg = config.services.palworld; join = builtins.concatStringsSep " "; in @@ -36,7 +36,7 @@ in description = "the amount of players to support"; }; secretFile = mkOption { - type = path; + type = nullOr path; default = "/etc/default/palworld"; description = ""; }; @@ -391,7 +391,7 @@ in { wantedBy = [ "multi-user.target" ]; serviceConfig = { - EnvironmentFile = cfg.secretFile; + ${if cfg.secretFile != null then "EnvironmentFile" else null} = cfg.secretFile; ExecStartPre = "${pkgs.bash}/bin/bash -c '${pre_command}'"; ExecStart = join [ "${pkgs.steam-run}/bin/steam-run ${dir}/Pal/Binaries/Linux/${cfg.serverBinary} Pal" diff --git a/hosts/modules/games/valheim.nix b/hosts/modules/games/valheim.nix index 768ba20c..2fd67742 100644 --- a/hosts/modules/games/valheim.nix +++ b/hosts/modules/games/valheim.nix @@ -1,7 +1,7 @@ { config, pkgs, lib, ... }: let inherit (lib) mkIf mkEnableOption mkOption; - inherit (lib.types) path port str; + inherit (lib.types) nullOr path port str; cfg = config.services.valheim; in { @@ -40,7 +40,7 @@ in description = "the name of the world to use"; }; secretFile = mkOption { - type = path; + type = nullOr path; default = "/etc/default/valheim"; description = '' this file contains any additional secrets you might want to pass in. @@ -64,7 +64,7 @@ in systemd.services.valheim = { wantedBy = [ "multi-user.target" ]; serviceConfig = { - EnvironmentFile = cfg.secretFile; + ${if cfg.secretFile != null then "EnvironmentFile" else null} = cfg.secretFile; ExecStartPre = '' ${pkgs.steamcmd}/bin/steamcmd \ +force_install_dir ${cfg.dataDir} \ diff --git a/hosts/modules/servers/README.md b/hosts/modules/servers/README.md index 32e14deb..43b93cf3 100644 --- a/hosts/modules/servers/README.md +++ b/hosts/modules/servers/README.md @@ -10,10 +10,18 @@ This directory contains misc servers implemented as nix modules! a service to run + watch a local executable +### [infinity.nix](./infinity.nix) + +[infinity](https://github.com/michaelfeil/infinity) embeddings server + ### [minifluxng.nix](./minifluxng.nix) miniflux +### [obligator.nix](./obligator.nix) + +[obligator](https://github.com/lastlogin-net/obligator) service + ### [poglets.nix](./poglets.nix) This NixOS module contains a service for [poglets](https://github.com/jpetrucciani/poglets) diff --git a/hosts/modules/servers/infinity.nix b/hosts/modules/servers/infinity.nix new file mode 100644 index 00000000..f545bf9f --- /dev/null +++ b/hosts/modules/servers/infinity.nix @@ -0,0 +1,110 @@ +{ config, pkgs, lib, ... }: +let + inherit (lib) mkIf mkEnableOption mkOption literalExpression; + inherit (lib.types) listOf nullOr package path port str; + cfg = config.services.infinity; + defaultUser = "infinity"; +in +{ + imports = [ ]; + + options.services.infinity = { + enable = mkEnableOption "infinity"; + package = mkOption { + type = package; + default = pkgs.python312Packages.infinity-emb; + defaultText = literalExpression "pkgs.python312Packages.infinity-emb"; + description = "The package to use for infinity"; + }; + address = mkOption { + type = str; + default = "0.0.0.0"; + description = ''the address to bind to''; + }; + port = mkOption { + type = port; + default = 7997; + description = ''the port to bind to''; + }; + models = mkOption { + type = listOf str; + default = [ + "nomic-ai/nomic-embed-text-v1.5" + # check out the MTEB leaderboard! + ### https://huggingface.co/spaces/mteb/leaderboard + # "jinaai/jina-embeddings-v3" + # "BAAI/bge-small-en-v1.5" + # "dunzhang/stella_en_400M_v5" # requires xformers? + ]; + description = "the list of embeddings models to load"; + }; + extraFlags = mkOption { + type = str; + description = "any extra flags to pass to infinity"; + default = ""; + }; + secretFile = mkOption { + type = nullOr path; + default = null; + # default = "/etc/default/infinity"; + description = ''secret env variables for infinity''; + }; + user = mkOption { + type = str; + description = '' + User under which to run the infinity service. + ''; + default = defaultUser; + }; + group = mkOption { + type = str; + description = '' + Group under which to run the infinity service. + ''; + default = defaultUser; + }; + dataDir = mkOption { + type = path; + default = "/var/lib/infinity"; + description = ''the data directory for infinity''; + }; + }; + + config = mkIf cfg.enable { + users.users.${cfg.user} = { + inherit (cfg) group; + home = cfg.dataDir; + createHome = true; + isSystemUser = true; + }; + users.groups.${cfg.group} = { }; + + systemd.services.infinity = + let + models = lib.concatStringsSep " " ( + map (model: "--model-id '${lib.replaceStrings ["'"] [""] model}'") cfg.models + ); + serve = pkgs.writers.writeBash "infinity-serve" '' + ${lib.getExe' cfg.package "infinity_emb"} v2 --host '${cfg.address}' --port '${toString cfg.port}' ${models} ${cfg.extraFlags} + ''; + in + { + after = [ "network.target" ]; + wantedBy = [ "multi-user.target" ]; + + environment = { + HOME = cfg.dataDir; + USER = cfg.user; + }; + + serviceConfig = { + ${if cfg.secretFile != null then "EnvironmentFile" else null} = cfg.secretFile; + ExecStart = serve; + Restart = "on-failure"; + StateDirectory = "infinity"; + User = cfg.user; + WorkingDirectory = cfg.dataDir; + }; + }; + }; +} diff --git a/hosts/modules/servers/zinc.nix b/hosts/modules/servers/zinc.nix index b4112442..bf9a5e0b 100644 --- a/hosts/modules/servers/zinc.nix +++ b/hosts/modules/servers/zinc.nix @@ -1,7 +1,7 @@ { config, pkgs, lib, ... }: let inherit (lib) mkIf mkEnableOption mkOption literalExpression; - inherit (lib.types) bool package path port str; + inherit (lib.types) bool nullOr package path port str; cfg = config.services.zinc; in { @@ -25,8 +25,9 @@ in description = ''the data directory for zinc''; }; secretFile = mkOption { - type = path; - default = "/etc/default/zinc"; + type = nullOr path; + default = null; + # default = "/etc/default/zinc"; description = ''secret env variables for zinc''; }; package = mkOption { @@ -99,7 +100,7 @@ in }; serviceConfig = { - EnvironmentFile = cfg.secretFile; + ${if cfg.secretFile != null then "EnvironmentFile" else null} = cfg.secretFile; ExecStart = '' ${cfg.package}/bin/zinc ''; diff --git a/hosts/neptune/configuration.nix b/hosts/neptune/configuration.nix index 3393b4b7..3669aa26 100644 --- a/hosts/neptune/configuration.nix +++ b/hosts/neptune/configuration.nix @@ -84,6 +84,7 @@ in port = 8420; controlPort = 8421; }; + infinity.enable = true; ombi = { enable = true; port = 5999; diff --git a/hosts/neptune/hardware-configuration.nix b/hosts/neptune/hardware-configuration.nix index 10bbeebe..52154997 100644 --- a/hosts/neptune/hardware-configuration.nix +++ b/hosts/neptune/hardware-configuration.nix @@ -14,17 +14,15 @@ extraModulePackages = [ ]; }; - fileSystems."/" = - { - device = "/dev/nvme0n1p2"; - fsType = "btrfs"; - }; + fileSystems."/" = { + device = "/dev/nvme0n1p2"; + fsType = "btrfs"; + }; - fileSystems."/boot" = - { - device = "/dev/disk/by-uuid/aadbe86d-0045-4122-915a-bbd33ef2aec3"; - fsType = "ext2"; - }; + fileSystems."/boot" = { + device = "/dev/disk/by-uuid/aadbe86d-0045-4122-915a-bbd33ef2aec3"; + fsType = "ext2"; + }; swapDevices = [ ]; diff --git a/hosts/nyx0/configuration.nix b/hosts/nyx0/configuration.nix index 0d835680..c12a9a15 100644 --- a/hosts/nyx0/configuration.nix +++ b/hosts/nyx0/configuration.nix @@ -50,9 +50,8 @@ in infinity = { enable = true; models = [ - "BAAI/bge-small-en-v1.5" "jinaai/jina-embeddings-v3" - "nomic-ai/nomic-embed-text-v1" + "nomic-ai/nomic-embed-text-v1.5" ]; }; llama-server.servers = { diff --git a/hosts/pluto/configuration.nix b/hosts/pluto/configuration.nix index 57a1609f..c1aefbeb 100644 --- a/hosts/pluto/configuration.nix +++ b/hosts/pluto/configuration.nix @@ -57,9 +57,8 @@ in infinity = { enable = true; models = [ - "BAAI/bge-small-en-v1.5" "jinaai/jina-embeddings-v3" - "nomic-ai/nomic-embed-text-v1" + "nomic-ai/nomic-embed-text-v1.5" ]; }; koboldcpp.servers = { diff --git a/hosts/styx/configuration.nix b/hosts/styx/configuration.nix index a2969592..32248da9 100644 --- a/hosts/styx/configuration.nix +++ b/hosts/styx/configuration.nix @@ -54,9 +54,9 @@ in infinity = { enable = true; models = [ - "BAAI/bge-small-en-v1.5" "jinaai/jina-embeddings-v3" - "nomic-ai/nomic-embed-text-v1" + "nomic-ai/nomic-embed-text-v1.5" + # "BAAI/bge-small-en-v1.5" # "dunzhang/stella_en_400M_v5" # requires xformers? ]; }; diff --git a/mods/python/ai/apps.nix b/mods/python/ai/apps.nix index c6e5aaa7..6facced7 100644 --- a/mods/python/ai/apps.nix +++ b/mods/python/ai/apps.nix @@ -457,6 +457,11 @@ in build-system = with final; [ poetry-core + pythonRelaxDepsHook + ]; + + pythonRelaxDeps = [ + "numpy" ]; dependencies = with final; [ @@ -465,6 +470,7 @@ in einops fastapi hf-transfer + httptools huggingface-hub numpy optimum diff --git a/pkgs/server/README.md b/pkgs/server/README.md index e69aaf20..0f824e9b 100644 --- a/pkgs/server/README.md +++ b/pkgs/server/README.md @@ -20,7 +20,7 @@ This directory contains specific servers ### [obligator.nix](./obligator.nix) -[obligator](https://github.com/anderspitman/obligator) is an OIDC server designed for self-hosters +[obligator](https://github.com/lastlogin-net/obligator) is an OIDC server designed for self-hosters ### [poglets.nix](./poglets.nix) diff --git a/pkgs/server/obligator.nix b/pkgs/server/obligator.nix index 6f0761bb..c3319ce1 100644 --- a/pkgs/server/obligator.nix +++ b/pkgs/server/obligator.nix @@ -1,4 +1,4 @@ -# [obligator](https://github.com/anderspitman/obligator) is an OIDC server designed for self-hosters +# [obligator](https://github.com/lastlogin-net/obligator) is an OIDC server designed for self-hosters { lib , buildGoModule , fetchFromGitHub @@ -22,7 +22,7 @@ buildGoModule { meta = with lib; { description = "Simple and opinionated OpenID Connect server designed for self-hosters"; - homepage = "https://github.com/anderspitman/obligator"; + homepage = "https://github.com/lastlogin-net/obligator"; license = licenses.mit; maintainers = with maintainers; [ jpetrucciani ]; mainProgram = "obligator";