2014-04-14 15:26:48 +01:00
|
|
|
{ config, lib, pkgs, ... }:
|
2014-03-07 19:09:59 +00:00
|
|
|
|
2014-04-14 15:26:48 +01:00
|
|
|
with lib;
|
2014-03-07 19:09:59 +00:00
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
cfg = config.services.searx;
|
|
|
|
|
|
|
|
configFile = cfg.configFile;
|
|
|
|
|
|
|
|
in
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
###### interface
|
|
|
|
|
|
|
|
options = {
|
|
|
|
|
|
|
|
services.searx = {
|
|
|
|
|
2017-04-04 16:14:32 +01:00
|
|
|
enable = mkEnableOption
|
|
|
|
"the searx server. See https://github.com/asciimoo/searx";
|
2014-03-07 19:09:59 +00:00
|
|
|
|
|
|
|
configFile = mkOption {
|
2017-04-04 16:14:32 +01:00
|
|
|
type = types.nullOr types.path;
|
|
|
|
default = null;
|
2014-03-07 19:09:59 +00:00
|
|
|
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).
|
|
|
|
";
|
|
|
|
};
|
|
|
|
|
2017-02-10 21:44:10 +00:00
|
|
|
package = mkOption {
|
2017-03-07 13:01:30 +00:00
|
|
|
type = types.package;
|
2017-08-01 00:11:36 +01:00
|
|
|
default = pkgs.searx;
|
|
|
|
defaultText = "pkgs.searx";
|
2017-02-10 21:44:10 +00:00
|
|
|
description = "searx package to use.";
|
|
|
|
};
|
|
|
|
|
2014-03-07 19:09:59 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
###### implementation
|
|
|
|
|
|
|
|
config = mkIf config.services.searx.enable {
|
|
|
|
|
2018-06-30 00:58:35 +01:00
|
|
|
users.users.searx =
|
2014-03-07 19:09:59 +00:00
|
|
|
{ uid = config.ids.uids.searx;
|
|
|
|
description = "Searx user";
|
|
|
|
createHome = true;
|
|
|
|
home = "/var/lib/searx";
|
|
|
|
};
|
|
|
|
|
2018-06-30 00:58:35 +01:00
|
|
|
users.groups.searx =
|
2014-03-07 19:09:59 +00:00
|
|
|
{ gid = config.ids.gids.searx;
|
|
|
|
};
|
|
|
|
|
|
|
|
systemd.services.searx =
|
|
|
|
{
|
|
|
|
description = "Searx server, the meta search engine.";
|
|
|
|
after = [ "network.target" ];
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
2014-03-09 17:57:17 +00:00
|
|
|
serviceConfig = {
|
|
|
|
User = "searx";
|
2017-02-10 21:44:10 +00:00
|
|
|
ExecStart = "${cfg.package}/bin/searx-run";
|
2014-03-09 17:57:17 +00:00
|
|
|
};
|
2017-04-04 16:14:32 +01:00
|
|
|
} // (optionalAttrs (configFile != null) {
|
2014-03-09 17:57:17 +00:00
|
|
|
environment.SEARX_SETTINGS_PATH = configFile;
|
|
|
|
});
|
2014-03-07 19:09:59 +00:00
|
|
|
|
2017-02-10 21:44:10 +00:00
|
|
|
environment.systemPackages = [ cfg.package ];
|
2014-03-07 19:09:59 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|