diff options
| author | Akshay Nair <phenax5@gmail.com> | 2026-03-21 23:00:24 +0530 |
|---|---|---|
| committer | Akshay Nair <phenax5@gmail.com> | 2026-03-21 23:00:24 +0530 |
| commit | cef61e5b571bdba43d8b81c253be505c897f4c4b (patch) | |
| tree | c1bc1d97a8561c5ade0d0b5aee07e5c01baa17a4 /services/omnisearch/default.nix | |
| parent | c5d02e0c371ca71a9a668bc15dfc63aaf5dc28f9 (diff) | |
| download | homeserver-nixos-config-cef61e5b571bdba43d8b81c253be505c897f4c4b.tar.gz homeserver-nixos-config-cef61e5b571bdba43d8b81c253be505c897f4c4b.zip | |
Omnisearch
Diffstat (limited to 'services/omnisearch/default.nix')
| -rw-r--r-- | services/omnisearch/default.nix | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/services/omnisearch/default.nix b/services/omnisearch/default.nix new file mode 100644 index 0000000..fb877e5 --- /dev/null +++ b/services/omnisearch/default.nix @@ -0,0 +1,77 @@ +{ + config, + pkgs, + lib, + ... +}: +with lib; +let + cfg = config.services.omnisearch; + omnisearch-pkg = import ./pkg.nix { inherit pkgs lib; }; +in +{ + options.services.omnisearch = { + enable = mkEnableOption "omnisearch metasearch engine"; + port = mkOption { + type = types.int; + default = 8087; + }; + host = mkOption { + type = types.str; + default = "0.0.0.0"; + }; + openFirewall = mkOption { + type = types.bool; + default = false; + }; + settings = mkOption { + type = types.attrs; + default = { }; + }; + }; + + config = mkIf cfg.enable { + systemd.services.omnisearch = { + enable = true; + script = "${omnisearch-pkg}/bin/omnisearch"; + serviceConfig = { + Type = "simple"; + User = "omnisearch"; + Group = "omnisearch"; + WorkingDirectory = "/etc/omnisearch"; + Restart = "always"; + RestartSec = 5; + PrivateTmp = true; + NoNewPrivileges = true; + }; + wantedBy = [ "multi-user.target" ]; + after = [ "network.target" ]; + }; + + users.groups.omnisearch = { }; + users.users.omnisearch = { + isSystemUser = true; + group = "omnisearch"; + shell = null; + }; + + networking.firewall.allowedTCPPorts = mkIf cfg.openFirewall [ + cfg.port + 5000 + ]; + + environment.systemPackages = [ omnisearch-pkg ]; + + environment.etc = { + "omnisearch/config.ini".text = generators.toINI { } ( + recursiveUpdate { + server.host = "0.0.0.0"; + server.port = cfg.port; + cache.dir = "/tmp/omnisearch_cache"; + } cfg.settings + ); + "omnisearch/templates".source = ./templates; + "omnisearch/static".source = ./static; + }; + }; +} |
