forked from NixOS/nixpkgs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request NixOS#335151 from drupol/nixos/chromadb/init
nixos/chromadb: init
- Loading branch information
Showing
6 changed files
with
143 additions
and
0 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
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,107 @@ | ||
{ | ||
config, | ||
pkgs, | ||
lib, | ||
... | ||
}: | ||
|
||
let | ||
cfg = config.services.chromadb; | ||
inherit (lib) | ||
mkEnableOption | ||
mkOption | ||
mkIf | ||
types | ||
literalExpression | ||
; | ||
in | ||
{ | ||
|
||
meta.maintainers = with lib.maintainers; [ drupol ]; | ||
|
||
options = { | ||
services.chromadb = { | ||
enable = mkEnableOption "ChromaDB, an open-source AI application database."; | ||
|
||
package = mkOption { | ||
type = types.package; | ||
example = literalExpression "pkgs.python3Packages.chromadb"; | ||
default = pkgs.python3Packages.chromadb; | ||
defaultText = "pkgs.python3Packages.chromadb"; | ||
description = "ChromaDB package to use."; | ||
}; | ||
|
||
host = mkOption { | ||
type = types.str; | ||
default = "127.0.0.1"; | ||
description = '' | ||
Defines the IP address by which ChromaDB will be accessible. | ||
''; | ||
}; | ||
|
||
port = mkOption { | ||
type = types.port; | ||
default = 8000; | ||
description = '' | ||
Defined the port number to listen. | ||
''; | ||
}; | ||
|
||
logFile = mkOption { | ||
type = types.path; | ||
default = "/var/log/chromadb/chromadb.log"; | ||
description = '' | ||
Specifies the location of file for logging output. | ||
''; | ||
}; | ||
|
||
dbpath = mkOption { | ||
type = types.str; | ||
default = "/var/lib/chromadb"; | ||
description = "Location where ChromaDB stores its files"; | ||
}; | ||
|
||
openFirewall = mkOption { | ||
type = types.bool; | ||
default = false; | ||
description = '' | ||
Whether to automatically open the specified TCP port in the firewall. | ||
''; | ||
}; | ||
}; | ||
}; | ||
|
||
config = mkIf cfg.enable { | ||
systemd.services.chromadb = { | ||
description = "ChromaDB"; | ||
after = [ "network.target" ]; | ||
wantedBy = [ "multi-user.target" ]; | ||
serviceConfig = { | ||
Type = "simple"; | ||
StateDirectory = "chromadb"; | ||
WorkingDirectory = "/var/lib/chromadb"; | ||
LogsDirectory = "chromadb"; | ||
ExecStart = "${lib.getExe cfg.package} run --path ${cfg.dbpath} --host ${cfg.host} --port ${toString cfg.port} --log-path ${cfg.logFile}"; | ||
Restart = "on-failure"; | ||
ProtectHome = true; | ||
ProtectSystem = "strict"; | ||
PrivateTmp = true; | ||
PrivateDevices = true; | ||
ProtectHostname = true; | ||
ProtectClock = true; | ||
ProtectKernelTunables = true; | ||
ProtectKernelModules = true; | ||
ProtectKernelLogs = true; | ||
ProtectControlGroups = true; | ||
NoNewPrivileges = true; | ||
RestrictRealtime = true; | ||
RestrictSUIDSGID = true; | ||
RemoveIPC = true; | ||
PrivateMounts = true; | ||
DynamicUser = true; | ||
}; | ||
}; | ||
|
||
networking.firewall.allowedTCPPorts = lib.optionals cfg.openFirewall [ cfg.port ]; | ||
}; | ||
} |
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,26 @@ | ||
{ lib, pkgs, ... }: | ||
|
||
let | ||
lib = pkgs.lib; | ||
|
||
in | ||
{ | ||
name = "chromadb"; | ||
meta.maintainers = [ lib.maintainers.drupol ]; | ||
|
||
nodes = { | ||
machine = | ||
{ pkgs, ... }: | ||
{ | ||
services.chromadb = { | ||
enable = true; | ||
}; | ||
}; | ||
}; | ||
|
||
testScript = '' | ||
machine.start() | ||
machine.wait_for_unit("chromadb.service") | ||
machine.wait_for_open_port(8000) | ||
''; | ||
} |
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