Skip to content

Commit f041f87

Browse files
drupolshivaraj-bh
authored andcommitted
feat(tika): init
1 parent e5c2e7c commit f041f87

File tree

5 files changed

+91
-0
lines changed

5 files changed

+91
-0
lines changed

doc/tika.md

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Tika
2+
3+
[Tika](https://tika.apache.org/) is a content analysis toolkit as a service that can detect and extract metadata and
4+
text from over a thousand different file types.
5+
6+
## Getting Started
7+
8+
```nix
9+
# In `perSystem.process-compose.<name>`
10+
{
11+
services.tika."instance-name" = {
12+
enable = true;
13+
port = 9998;
14+
host = "127.0.0.1";
15+
};
16+
}
17+
```

nix/services/default.nix

+1
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,6 @@ in
2121
./tempo.nix
2222
./weaviate.nix
2323
./searxng.nix
24+
./tika.nix
2425
];
2526
}

nix/services/tika.nix

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
{ pkgs, lib, name, config, ... }:
2+
let
3+
inherit (lib) types literalExpression;
4+
in
5+
{
6+
options = {
7+
package = lib.mkPackageOption pkgs "tika" { };
8+
9+
host = lib.mkOption {
10+
description = "Apache Tika bind address";
11+
default = "127.0.0.1";
12+
example = "0.0.0.0";
13+
type = types.str;
14+
};
15+
16+
port = lib.mkOption {
17+
description = "Apache Tika port to listen on";
18+
default = 9998;
19+
type = types.port;
20+
};
21+
22+
configFile = lib.mkOption {
23+
type = types.nullOr types.path;
24+
default = null;
25+
description = ''
26+
The Apache Tika configuration (XML) file to use.
27+
'';
28+
example = literalExpression "./tika/tika-config.xml";
29+
};
30+
};
31+
32+
config = {
33+
outputs = {
34+
settings = {
35+
processes = {
36+
"${name}" = {
37+
command = "${lib.getExe config.package} --host ${config.host} --port ${toString config.port} ${lib.optionalString (config.configFile != null) "--config ${config.configFile}"}";
38+
availability.restart = "on_failure";
39+
readiness_probe = {
40+
http_get = {
41+
host = config.host;
42+
port = config.port;
43+
};
44+
initial_delay_seconds = 2;
45+
period_seconds = 10;
46+
timeout_seconds = 4;
47+
success_threshold = 1;
48+
failure_threshold = 5;
49+
};
50+
};
51+
};
52+
};
53+
};
54+
};
55+
}

nix/services/tika_test.nix

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{ pkgs, ... }:
2+
{
3+
services.tika."tika1" = {
4+
enable = true;
5+
};
6+
7+
settings.processes.test = {
8+
command = pkgs.writeShellApplication {
9+
runtimeInputs = [ pkgs.curl ];
10+
text = ''
11+
curl http://127.0.0.1:9998
12+
'';
13+
name = "tika-test";
14+
};
15+
depends_on."tika1".condition = "process_healthy";
16+
};
17+
}

test/flake.nix

+1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
"${inputs.services-flake}/nix/services/pgadmin_test.nix"
5050
"${inputs.services-flake}/nix/services/tempo_test.nix"
5151
"${inputs.services-flake}/nix/services/weaviate_test.nix"
52+
"${inputs.services-flake}/nix/services/tika_test.nix"
5253
]));
5354
};
5455
};

0 commit comments

Comments
 (0)