nixpkgs/nixos/modules/services/networking/searx.nix

84 lines
1.7 KiB
Nix
Raw Normal View History

{ config, lib, pkgs, ... }:
2014-03-07 19:09:59 +00:00
with lib;
2014-03-07 19:09:59 +00:00
let
cfg = config.services.searx;
configFile = cfg.configFile;
in
{
###### interface
options = {
services.searx = {
enable = mkOption {
2017-03-07 13:01:30 +00:00
type = types.bool;
2014-03-07 19:09:59 +00:00
default = false;
description = "
2014-03-09 17:57:17 +00:00
Whether to enable the Searx server. See https://github.com/asciimoo/searx
2014-03-07 19:09:59 +00:00
";
};
configFile = mkOption {
2017-03-07 13:01:30 +00:00
type = types.path;
2014-03-07 19:09:59 +00:00
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).
";
};
package = mkOption {
2017-03-07 13:01:30 +00:00
type = types.package;
default = pkgs.pythonPackages.searx;
defaultText = "pkgs.pythonPackages.searx";
description = "searx package to use.";
};
2014-03-07 19:09:59 +00:00
};
};
###### 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" ];
2014-03-09 17:57:17 +00:00
serviceConfig = {
User = "searx";
ExecStart = "${cfg.package}/bin/searx-run";
2014-03-09 17:57:17 +00:00
};
} // (optionalAttrs (configFile != "") {
environment.SEARX_SETTINGS_PATH = configFile;
});
2014-03-07 19:09:59 +00:00
environment.systemPackages = [ cfg.package ];
2014-03-07 19:09:59 +00:00
};
}