Skip to content

searxng: init #241

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jun 20, 2024
Merged

searxng: init #241

merged 7 commits into from
Jun 20, 2024

Conversation

drupol
Copy link
Contributor

@drupol drupol commented Jun 19, 2024

This PR:

  • Add the searxng service

Test with:

{
  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
    flake-parts.url = "github:hercules-ci/flake-parts";
    systems.url = "github:nix-systems/default";
    process-compose-flake.url = "github:Platonic-Systems/process-compose-flake";
    services-flake.url = "github:juspay/services-flake";
  };
  outputs =
    inputs:
    inputs.flake-parts.lib.mkFlake { inherit inputs; } {
      systems = import inputs.systems;
      imports = [ inputs.process-compose-flake.flakeModule ];
      perSystem =
        { pkgs, lib, ... }:
        {
          # `process-compose.foo` will add a flake package output called "foo".
          # Therefore, this will add a default package that you can build using
          # `nix build` and run using `nix run`.
          process-compose."default" =
            pc:
            let
              inherit (pc.config.services.searxng.searxng) host port;
            in
            {
              imports = [ inputs.services-flake.processComposeModules.default ];

              services.searxng."searxng" = {
                enable = true;
                settings = {
                  use_default_settings = true;
                  server.secret_key = "secret";
                  server.limiter = false;
                };
              };

              # Open the browser after the Open WebUI service has started
              settings.processes.open-browser = {
                command =
                  let
                    opener = if pkgs.stdenv.isDarwin then "open" else lib.getExe' pkgs.xdg-utils "xdg-open";
                    url = "http://${host}:${toString port}";
                  in
                  "${opener} ${url}";
                depends_on.searxng.condition = "process_healthy";
              };
            };
        };
    };
}

@srid srid requested review from srid and shivaraj-bh June 19, 2024 15:25
@drupol drupol marked this pull request as ready for review June 19, 2024 15:49
@shivaraj-bh
Copy link
Member

I just tried it out with the following settings:

{
  services.searxng."searxng1" = {
    enable = true;
    settings = {
      use_default_settings = true;
      server.secret_key = "secret";
      search.formats = [ "html" "json" ];
    };
  };
}

And tried out the json format output with curl:

❯ curl -G 'http://localhost:1234/search' \
  --data-urlencode 'q=OpenAI' \
  --data-urlencode 'format=json' | jq '.results | .[:1]'
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 34975  100 34975    0     0  11099      0  0:00:03  0:00:03 --:--:-- 11099
[
  {
    "url": "https://openai.com/",
    "title": "OpenAI",
    "content": "OpenAI announces GPT-4o, a new version of its powerful language model, and ChatGPT, a free service that lets you chat with it. Learn more about their research, products, and mission to create safe and beneficial artificial general intelligence.",
    "thumbnail": "",
    "engine": "google",
    "parsed_url": [
      "https",
      "openai.com",
      "/",
      "",
      "",
      ""
    ],
    "template": "default.html",
    "engines": [
      "duckduckgo",
      "google",
      "brave"
    ],
    "positions": [
      1,
      1,
      1,
      2
    ],
    "publishedDate": "2024-05-13T00:00:00",
    "score": 14.0,
    "category": "general"
  }
]

pretty cool! will be really helpful to provide search engine access to agents.

@drupol
Copy link
Contributor Author

drupol commented Jun 19, 2024

pretty cool! will be really helpful to provide search engine access to agents.

Already using it in conjunction with open-webui on my server, that's the reason why I did this PR.

Copy link
Member

@srid srid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM from my side.

Can merge after @shivaraj-bh review (and addressing of comments) with CI fully passing (currently fails on mac).

@shivaraj-bh
Copy link
Member

Can merge after @shivaraj-bh review (and addressing of comments) with CI fully passing (currently fails on mac).

For the time-being, we can disable tests for this package on Darwin (like we do for grafana), with a comment linking to upstream issue: NixOS/nixpkgs#321329.

@drupol
Copy link
Contributor Author

drupol commented Jun 20, 2024

I think i'm done.

@shivaraj-bh shivaraj-bh merged commit f3098fa into juspay:main Jun 20, 2024
2 checks passed
@drupol drupol deleted the searxng branch June 20, 2024 20:09
@drupol
Copy link
Contributor Author

drupol commented Jun 20, 2024

Top! thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants