Unverified Commit 1a8e33d4 authored by Pol Dellaiera's avatar Pol Dellaiera Committed by GitHub
Browse files

Merge pull request #326532 from drupol/module/add-tika

nixos/tika: init module
parents 61bd9691 c8bf7321
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -36,6 +36,8 @@

- [Glance](https://github.com/glanceapp/glance), a self-hosted dashboard that puts all your feeds in one place. Available as [services.glance](option.html#opt-services.glance).

- [Apache Tika](https://github.com/apache/tika), a toolkit that detects and extracts metadata and text from over a thousand different file types. Available as [services.tika](option.html#opt-services.tika).

## Backward Incompatibilities {#sec-release-24.11-incompatibilities}

- `transmission` package has been aliased with a `trace` warning to `transmission_3`. Since [Transmission 4 has been released last year](https://github.com/transmission/transmission/releases/tag/4.0.0), and Transmission 3 will eventually go away, it was decided perform this warning alias to make people aware of the new version. The `services.transmission.package` defaults to `transmission_3` as well because the upgrade can cause data loss in certain specific usage patterns (examples: [#5153](https://github.com/transmission/transmission/issues/5153), [#6796](https://github.com/transmission/transmission/issues/6796)). Please make sure to back up to your data directory per your usage:
+1 −0
Original line number Diff line number Diff line
@@ -1264,6 +1264,7 @@
  ./services/search/qdrant.nix
  ./services/search/quickwit.nix
  ./services/search/sonic-server.nix
  ./services/search/tika.nix
  ./services/search/typesense.nix
  ./services/security/aesmd.nix
  ./services/security/authelia.nix
+84 −0
Original line number Diff line number Diff line
{
  config,
  lib,
  pkgs,
  ...
}:

let
  cfg = config.services.tika;
  inherit (lib)
    literalExpression
    mkIf
    mkEnableOption
    mkOption
    mkPackageOption
    getExe
    types
    ;
in
{
  meta.maintainers = [ lib.maintainers.drupol ];

  options = {
    services.tika = {
      enable = mkEnableOption "Apache Tika server";
      package = mkPackageOption pkgs "tika" { };

      listenAddress = mkOption {
        type = types.str;
        default = "127.0.0.1";
        example = "0.0.0.0";
        description = ''
          The Apache Tika bind address.
        '';
      };

      port = mkOption {
        type = types.port;
        default = 9998;
        description = ''
          The Apache Tike port to listen on
        '';
      };

      configFile = mkOption {
        type = types.nullOr types.path;
        default = null;
        description = ''
          The Apache Tika configuration (XML) file to use.
        '';
        example = literalExpression "./tika/tika-config.xml";
      };

      openFirewall = mkOption {
        type = types.bool;
        default = false;
        description = ''
          Whether to open the firewall for Apache Tika.
          This adds `services.tika.port` to `networking.firewall.allowedTCPPorts`.
        '';
      };
    };
  };

  config = mkIf cfg.enable {
    systemd.services.tika = {
      description = "Apache Tika Server";

      wantedBy = [ "multi-user.target" ];
      after = [ "network.target" ];

      serviceConfig = {
        Type = "simple";

        ExecStart = "${getExe cfg.package} --host ${cfg.listenAddress} --port ${toString cfg.port} ${lib.optionalString (cfg.configFile != null) "--config ${cfg.configFile}"}";
        DynamicUser = true;
        StateDirectory = "tika";
        CacheDirectory = "tika";
      };
    };

    networking.firewall = mkIf cfg.openFirewall { allowedTCPPorts = [ cfg.port ]; };
  };
}
+1 −0
Original line number Diff line number Diff line
@@ -980,6 +980,7 @@ in {
  thanos = handleTest ./thanos.nix {};
  tiddlywiki = handleTest ./tiddlywiki.nix {};
  tigervnc = handleTest ./tigervnc.nix {};
  tika = runTest ./tika.nix;
  timescaledb = handleTest ./timescaledb.nix {};
  timezone = handleTest ./timezone.nix {};
  tinc = handleTest ./tinc {};

nixos/tests/tika.nix

0 → 100644
+21 −0
Original line number Diff line number Diff line
{ lib, ... }:

{
  name = "tika-server";

  nodes = {
    machine = { pkgs, ... }: {
      services.tika = {
        enable = true;
      };
    };
  };

  testScript = ''
    machine.start()
    machine.wait_for_unit("tika.service")
    machine.wait_for_open_port(9998)
  '';

  meta.maintainers = [ lib.maintainers.drupol ];
}
Loading