9 cfg = config.services.chromadb;
20 meta.maintainers = with lib.maintainers; [ drupol ];
24 enable = mkEnableOption "ChromaDB, an open-source AI application database.";
28 example = literalExpression "pkgs.python3Packages.chromadb";
29 default = pkgs.python3Packages.chromadb;
30 defaultText = "pkgs.python3Packages.chromadb";
31 description = "ChromaDB package to use.";
36 default = "127.0.0.1";
38 Defines the IP address by which ChromaDB will be accessible.
46 Defined the port number to listen.
52 default = "/var/log/chromadb/chromadb.log";
54 Specifies the location of file for logging output.
60 default = "/var/lib/chromadb";
61 description = "Location where ChromaDB stores its files";
64 openFirewall = mkOption {
68 Whether to automatically open the specified TCP port in the firewall.
74 config = mkIf cfg.enable {
75 systemd.services.chromadb = {
76 description = "ChromaDB";
77 after = [ "network.target" ];
78 wantedBy = [ "multi-user.target" ];
81 StateDirectory = "chromadb";
82 WorkingDirectory = "/var/lib/chromadb";
83 LogsDirectory = "chromadb";
84 ExecStart = "${lib.getExe cfg.package} run --path ${cfg.dbpath} --host ${cfg.host} --port ${toString cfg.port} --log-path ${cfg.logFile}";
85 Restart = "on-failure";
87 ProtectSystem = "strict";
89 PrivateDevices = true;
90 ProtectHostname = true;
92 ProtectKernelTunables = true;
93 ProtectKernelModules = true;
94 ProtectKernelLogs = true;
95 ProtectControlGroups = true;
96 NoNewPrivileges = true;
97 RestrictRealtime = true;
98 RestrictSUIDSGID = true;
100 PrivateMounts = true;
105 networking.firewall.allowedTCPPorts = lib.optionals cfg.openFirewall [ cfg.port ];