about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPol Dellaiera <pol.dellaiera@protonmail.com>2024-06-19 13:56:01 +0200
committerGitHub <noreply@github.com>2024-06-19 13:56:01 +0200
commitc249dd3effcb56cb34b4a4b771d759e75ffeee44 (patch)
treeff42896561d9b77dd4d2dedf363875fe5ab04566
parenta24e65d7271969651c6ff2681013e2eb8d117a76 (diff)
parent7e1f057a06b572fd3167dd7d8f6ab340a9432285 (diff)
Merge pull request #320935 from drupol/bump/searxng/june-2024
searxng: 0-unstable-2024-05-31 -> 0-unstable-2024-06-19
-rw-r--r--nixos/tests/all-tests.nix2
-rw-r--r--nixos/tests/searx.nix182
-rw-r--r--pkgs/by-name/se/searxng/package.nix157
3 files changed, 177 insertions, 164 deletions
diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix
index 708332a9317b5..6b5ee429f9a22 100644
--- a/nixos/tests/all-tests.nix
+++ b/nixos/tests/all-tests.nix
@@ -834,7 +834,7 @@ in {
   scrutiny = handleTest ./scrutiny.nix {};
   sddm = handleTest ./sddm.nix {};
   seafile = handleTest ./seafile.nix {};
-  searx = handleTest ./searx.nix {};
+  searx = runTest ./searx.nix;
   seatd = handleTest ./seatd.nix {};
   service-runner = handleTest ./service-runner.nix {};
   sftpgo = runTest ./sftpgo.nix;
diff --git a/nixos/tests/searx.nix b/nixos/tests/searx.nix
index 02a88f690db78..0008424f068b2 100644
--- a/nixos/tests/searx.nix
+++ b/nixos/tests/searx.nix
@@ -1,4 +1,4 @@
-import ./make-test-python.nix ({ pkgs, ...} :
+{ pkgs, ... }:
 
 {
   name = "searx";
@@ -7,108 +7,108 @@ import ./make-test-python.nix ({ pkgs, ...} :
   };
 
   # basic setup: searx running the built-in webserver
-  nodes.base = { ... }: {
-    imports = [ ../modules/profiles/minimal.nix ];
-
-    services.searx = {
-      enable = true;
-      environmentFile = pkgs.writeText "secrets" ''
-        WOLFRAM_API_KEY  = sometoken
-        SEARX_SECRET_KEY = somesecret
-      '';
+  nodes.base =
+    { ... }:
+    {
+      services.searx = {
+        enable = true;
+        environmentFile = pkgs.writeText "secrets" ''
+          WOLFRAM_API_KEY  = sometoken
+          SEARX_SECRET_KEY = somesecret
+        '';
 
-      settings.server =
-        { port = "8080";
+        settings.server = {
+          port = "8080";
           bind_address = "0.0.0.0";
           secret_key = "@SEARX_SECRET_KEY@";
         };
-      settings.engines = [
-        { name = "wolframalpha";
-          api_key = "@WOLFRAM_API_KEY@";
-          engine = "wolframalpha_api";
-        }
-        { name = "startpage";
-          shortcut = "start";
-        }
-      ];
-    };
+        settings.engines = [
+          {
+            name = "wolframalpha";
+            api_key = "@WOLFRAM_API_KEY@";
+            engine = "wolframalpha_api";
+          }
+          {
+            name = "startpage";
+            shortcut = "start";
+          }
+        ];
+      };
 
-  };
+    };
 
   # fancy setup: run in uWSGI and use nginx as proxy
-  nodes.fancy = { config, ... }: {
-    imports = [ ../modules/profiles/minimal.nix ];
-
-    services.searx = {
-      enable = true;
-      # searx refuses to run if unchanged
-      settings.server.secret_key = "somesecret";
-
-      runInUwsgi = true;
-      uwsgiConfig = {
-        # serve using the uwsgi protocol
-        socket = "/run/searx/uwsgi.sock";
-        chmod-socket = "660";
-
-        # use /searx as url "mountpoint"
-        mount = "/searx=searx.webapp:application";
-        module = "";
-        manage-script-name = true;
+  nodes.fancy =
+    { config, ... }:
+    {
+      services.searx = {
+        enable = true;
+        # searx refuses to run if unchanged
+        settings.server.secret_key = "somesecret";
+
+        runInUwsgi = true;
+        uwsgiConfig = {
+          # serve using the uwsgi protocol
+          socket = "/run/searx/uwsgi.sock";
+          chmod-socket = "660";
+
+          # use /searx as url "mountpoint"
+          mount = "/searx=searx.webapp:application";
+          module = "";
+          manage-script-name = true;
+        };
       };
-    };
 
-    # use nginx as reverse proxy
-    services.nginx.enable = true;
-    services.nginx.virtualHosts.localhost = {
-      locations."/searx".extraConfig =
-        ''
+      # use nginx as reverse proxy
+      services.nginx.enable = true;
+      services.nginx.virtualHosts.localhost = {
+        locations."/searx".extraConfig = ''
           include ${pkgs.nginx}/conf/uwsgi_params;
           uwsgi_pass unix:/run/searx/uwsgi.sock;
         '';
-      locations."/searx/static/".alias = "${config.services.searx.package}/share/static/";
-    };
-
-    # allow nginx access to the searx socket
-    users.users.nginx.extraGroups = [ "searx" ];
-
-  };
-
-  testScript =
-    ''
-      base.start()
-
-      with subtest("Settings have been merged"):
-          base.wait_for_unit("searx-init")
-          base.wait_for_file("/run/searx/settings.yml")
-          output = base.succeed(
-              "${pkgs.yq-go}/bin/yq eval"
-              " '.engines[] | select(.name==\"startpage\") | .shortcut'"
-              " /run/searx/settings.yml"
-          ).strip()
-          assert output == "start", "Settings not merged"
+        locations."/searx/static/".alias = "${config.services.searx.package}/share/static/";
+      };
 
-      with subtest("Environment variables have been substituted"):
-          base.succeed("grep -q somesecret /run/searx/settings.yml")
-          base.succeed("grep -q sometoken /run/searx/settings.yml")
-          base.copy_from_vm("/run/searx/settings.yml")
+      # allow nginx access to the searx socket
+      users.users.nginx.extraGroups = [ "searx" ];
 
-      with subtest("Basic setup is working"):
-          base.wait_for_open_port(8080)
-          base.wait_for_unit("searx")
-          base.succeed(
-              "${pkgs.curl}/bin/curl --fail http://localhost:8080"
-          )
-          base.shutdown()
+    };
 
-      with subtest("Nginx+uWSGI setup is working"):
-          fancy.start()
-          fancy.wait_for_open_port(80)
-          fancy.wait_for_unit("uwsgi")
-          fancy.succeed(
-              "${pkgs.curl}/bin/curl --fail http://localhost/searx >&2"
-          )
-          fancy.succeed(
-              "${pkgs.curl}/bin/curl --fail http://localhost/searx/static/themes/simple/js/leaflet.js >&2"
-          )
-    '';
-})
+  testScript = ''
+    base.start()
+
+    with subtest("Settings have been merged"):
+        base.wait_for_unit("searx-init")
+        base.wait_for_file("/run/searx/settings.yml")
+        output = base.succeed(
+            "${pkgs.yq-go}/bin/yq eval"
+            " '.engines[] | select(.name==\"startpage\") | .shortcut'"
+            " /run/searx/settings.yml"
+        ).strip()
+        assert output == "start", "Settings not merged"
+
+    with subtest("Environment variables have been substituted"):
+        base.succeed("grep -q somesecret /run/searx/settings.yml")
+        base.succeed("grep -q sometoken /run/searx/settings.yml")
+        base.copy_from_vm("/run/searx/settings.yml")
+
+    with subtest("Basic setup is working"):
+        base.wait_for_open_port(8080)
+        base.wait_for_unit("searx")
+        base.succeed(
+            "${pkgs.curl}/bin/curl --fail http://localhost:8080"
+        )
+        base.shutdown()
+
+    with subtest("Nginx+uWSGI setup is working"):
+        fancy.start()
+        fancy.wait_for_open_port(80)
+        fancy.wait_for_unit("uwsgi")
+        fancy.succeed(
+            "${pkgs.curl}/bin/curl --fail http://localhost/searx >&2"
+        )
+        fancy.succeed(
+            "${pkgs.curl}/bin/curl --fail http://localhost/searx/static/themes/simple/js/leaflet.js >&2"
+        )
+  '';
+}
diff --git a/pkgs/by-name/se/searxng/package.nix b/pkgs/by-name/se/searxng/package.nix
index 7bca3ca181a79..4270088a5d293 100644
--- a/pkgs/by-name/se/searxng/package.nix
+++ b/pkgs/by-name/se/searxng/package.nix
@@ -1,84 +1,97 @@
-{ lib
-, python3
-, fetchFromGitHub
+{
+  lib,
+  python3,
+  fetchFromGitHub,
+  nixosTests
 }:
 
-python3.pkgs.toPythonModule (python3.pkgs.buildPythonApplication rec {
-  pname = "searxng";
-  version = "0-unstable-2024-05-31";
+python3.pkgs.toPythonModule (
+  python3.pkgs.buildPythonApplication rec {
+    pname = "searxng";
+    version = "0-unstable-2024-06-19";
 
-  src = fetchFromGitHub {
-    owner = "searxng";
-    repo = "searxng";
-    rev = "18fb701be225560b3fb1011cc533f785823f26a4";
-    hash = "sha256-okE/Uxl7YqcM99kLJ4KAlMQi50x5m0bPfYp5bv62WEw=";
-  };
+    src = fetchFromGitHub {
+      owner = "searxng";
+      repo = "searxng";
+      rev = "acf3f109b2a99a5e6f25f5f2975016a36673c6ef";
+      hash = "sha256-NdFnB5JEaWo7gt+RwxKxkVtEL8uGLlc4z0ROHN+zoL4=";
+    };
 
-  postPatch = ''
-    sed -i 's/==.*$//' requirements.txt
+    postPatch = ''
+      sed -i 's/==.*$//' requirements.txt
+    '';
 
-    # can't be fetchpatched as it is essentially empty and it complains about that
-    # TODO: drop when updating to a version that includes https://github.com/searxng/searxng/pull/3563
-    touch searx/answerers/random/__init__.py
-    touch searx/answerers/statistics/__init__.py
-  '';
+    preBuild =
+      let
+        versionString = lib.concatStringsSep "." (
+          builtins.tail (lib.splitString "-" (lib.removePrefix "0-" version))
+        );
+        commitAbbrev = builtins.substring 0 8 src.rev;
+      in
+      ''
+        export SEARX_DEBUG="true";
 
-  preBuild =
-    let
-      versionString = lib.concatStringsSep "." (builtins.tail (lib.splitString "-" (lib.removePrefix "0-" version)));
-      commitAbbrev = builtins.substring 0 8 src.rev;
-    in
-    ''
-      export SEARX_DEBUG="true";
+        cat > searx/version_frozen.py <<EOF
+        VERSION_STRING="${versionString}+${commitAbbrev}"
+        VERSION_TAG="${versionString}+${commitAbbrev}"
+        DOCKER_TAG="${versionString}-${commitAbbrev}"
+        GIT_URL="https://github.com/searxng/searxng"
+        GIT_BRANCH="master"
+        EOF
+      '';
 
-      cat > searx/version_frozen.py <<EOF
-      VERSION_STRING="${versionString}+${commitAbbrev}"
-      VERSION_TAG="${versionString}+${commitAbbrev}"
-      DOCKER_TAG="${versionString}-${commitAbbrev}"
-      GIT_URL="https://github.com/searxng/searxng"
-      GIT_BRANCH="master"
-      EOF
-    '';
+    dependencies =
+      with python3.pkgs;
+      [
+        babel
+        certifi
+        python-dateutil
+        fasttext-predict
+        flask
+        flask-babel
+        brotli
+        jinja2
+        lxml
+        pygments
+        pytomlpp
+        pyyaml
+        redis
+        uvloop
+        setproctitle
+        httpx
+        httpx-socks
+        markdown-it-py
+      ]
+      ++ httpx.optional-dependencies.http2
+      ++ httpx-socks.optional-dependencies.asyncio;
 
-  propagatedBuildInputs = with python3.pkgs; [
-    babel
-    certifi
-    python-dateutil
-    fasttext-predict
-    flask
-    flask-babel
-    brotli
-    jinja2
-    lxml
-    pygments
-    pytomlpp
-    pyyaml
-    redis
-    uvloop
-    setproctitle
-    httpx
-    httpx-socks
-    markdown-it-py
-  ] ++ httpx.optional-dependencies.http2
-  ++ httpx-socks.optional-dependencies.asyncio;
+    # tests try to connect to network
+    doCheck = false;
 
-  # tests try to connect to network
-  doCheck = false;
+    postInstall = ''
+      # Create a symlink for easier access to static data
+      mkdir -p $out/share
+      ln -s ../${python3.sitePackages}/searx/static $out/share/
 
-  postInstall = ''
-    # Create a symlink for easier access to static data
-    mkdir -p $out/share
-    ln -s ../${python3.sitePackages}/searx/static $out/share/
+      # copy config schema for the limiter
+      cp searx/limiter.toml $out/${python3.sitePackages}/searx/limiter.toml
+    '';
 
-    # copy config schema for the limiter
-    cp searx/limiter.toml $out/${python3.sitePackages}/searx/limiter.toml
-  '';
+    passthru = {
+      tests = {
+        searxng = nixosTests.searx;
+      };
+    };
 
-  meta = with lib; {
-    homepage = "https://github.com/searxng/searxng";
-    description = "Fork of Searx, a privacy-respecting, hackable metasearch engine";
-    license = licenses.agpl3Plus;
-    mainProgram = "searxng-run";
-    maintainers = with maintainers; [ SuperSandro2000 _999eagle ];
-  };
-})
+    meta = with lib; {
+      homepage = "https://github.com/searxng/searxng";
+      description = "Fork of Searx, a privacy-respecting, hackable metasearch engine";
+      license = licenses.agpl3Plus;
+      mainProgram = "searxng-run";
+      maintainers = with maintainers; [
+        SuperSandro2000
+        _999eagle
+      ];
+    };
+  }
+)