-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
lots of tweaks, add infinity nixos module (#1797)
- Loading branch information
1 parent
5c995fd
commit 5e6563f
Showing
16 changed files
with
155 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -106,6 +106,7 @@ in | |
util = [ | ||
"dbeaver-community" | ||
"docker" | ||
"ghostty" | ||
"insomnia" | ||
"karabiner-elements" | ||
"keybase" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
}; | ||
}; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -84,6 +84,7 @@ in | |
port = 8420; | ||
controlPort = 8421; | ||
}; | ||
infinity.enable = true; | ||
ombi = { | ||
enable = true; | ||
port = 5999; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters