summary refs log tree commit diff
path: root/nixos/modules/services/networking/searx.nix
diff options
context:
space:
mode:
authorMatej Cotman <cotman.matej@gmail.com>2014-03-07 20:09:59 +0100
committerDomen Kozar <domen@dev.si>2014-03-09 17:33:56 +0100
commit7e932ca4e293c1a4eb558427bf5a0c1c1c4b6817 (patch)
tree838137d8799b252981a8f2a95954eb062db59bc8 /nixos/modules/services/networking/searx.nix
parentbba7fb62e831ee1b225705b3d320f5819d6e8f81 (diff)
downloadnixpkgs-7e932ca4e293c1a4eb558427bf5a0c1c1c4b6817.tar
nixpkgs-7e932ca4e293c1a4eb558427bf5a0c1c1c4b6817.tar.gz
nixpkgs-7e932ca4e293c1a4eb558427bf5a0c1c1c4b6817.tar.bz2
nixpkgs-7e932ca4e293c1a4eb558427bf5a0c1c1c4b6817.tar.lz
nixpkgs-7e932ca4e293c1a4eb558427bf5a0c1c1c4b6817.tar.xz
nixpkgs-7e932ca4e293c1a4eb558427bf5a0c1c1c4b6817.tar.zst
nixpkgs-7e932ca4e293c1a4eb558427bf5a0c1c1c4b6817.zip
searx: add module
Diffstat (limited to 'nixos/modules/services/networking/searx.nix')
-rw-r--r--nixos/modules/services/networking/searx.nix76
1 files changed, 76 insertions, 0 deletions
diff --git a/nixos/modules/services/networking/searx.nix b/nixos/modules/services/networking/searx.nix
new file mode 100644
index 00000000000..e777239d478
--- /dev/null
+++ b/nixos/modules/services/networking/searx.nix
@@ -0,0 +1,76 @@
+{ config, pkgs, ... }:
+
+with pkgs.lib;
+
+let
+
+  cfg = config.services.searx;
+
+  configFile = cfg.configFile;
+
+in
+
+{
+
+  ###### interface
+
+  options = {
+
+    services.searx = {
+
+      enable = mkOption {
+        default = false;
+        description = "
+          Whether to enable the Searx server.
+        ";
+      };
+
+      configFile = mkOption {
+        default = "";
+        description = "
+          The path of the Searx server configuration file. If no file
+          is specified, a default file is used (default config file has
+          debug mode enabled).
+        ";
+      };
+
+    };
+
+  };
+
+
+  ###### implementation
+
+  config = mkIf config.services.searx.enable {
+
+    users.extraUsers.searx =
+      { uid = config.ids.uids.searx;
+        description = "Searx user";
+        createHome = true;
+        home = "/var/lib/searx";
+      };
+
+    users.extraGroups.searx =
+      { gid = config.ids.gids.searx;
+      };
+
+    systemd.services.searx =
+      {
+        description = "Searx server, the meta search engine.";
+        after = [ "network.target" ];
+        wantedBy = [ "multi-user.target" ];
+        serviceConfig.User = "searx";
+        script = ''
+            if [ -z "${configFile}" ]; then
+              exec ${pkgs.pythonPackages.searx}/bin/searx-run
+            else
+              SEARX_SETTINGS_PATH="${configFile}" exec ${pkgs.pythonPackages.searx}/bin/searx-run
+            fi
+        '';
+      };
+
+    environment.systemPackages = [ pkgs.pythonPackages.searx ];
+
+  };
+
+}