blob: 2b37b3308433b825890b9057c9d2bb8d35656323 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
{
config,
lib,
pkgs,
...
}:
let
cfg = config.services.whoogle-search;
in
{
options = {
services.whoogle-search = {
enable = lib.mkEnableOption "Whoogle, a metasearch engine";
port = lib.mkOption {
type = lib.types.port;
default = 5000;
description = "Port to listen on.";
};
listenAddress = lib.mkOption {
type = lib.types.str;
default = "127.0.0.1";
description = "Address to listen on for the web interface.";
};
extraEnv = lib.mkOption {
type = with lib.types; attrsOf str;
default = { };
description = ''
Extra environment variables to pass to Whoogle, see
https://github.com/benbusby/whoogle-search?tab=readme-ov-file#environment-variables
'';
};
};
};
config = lib.mkIf cfg.enable {
systemd.services.whoogle-search = {
description = "Whoogle Search";
wantedBy = [ "multi-user.target" ];
path = [ pkgs.whoogle-search ];
environment = {
CONFIG_VOLUME = "/var/lib/whoogle-search";
}
// cfg.extraEnv;
serviceConfig = {
Type = "simple";
ExecStart =
"${lib.getExe pkgs.whoogle-search}"
+ " --host '${cfg.listenAddress}'"
+ " --port '${toString cfg.port}'";
ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID";
StateDirectory = "whoogle-search";
StateDirectoryMode = "0750";
DynamicUser = true;
PrivateTmp = true;
ProtectSystem = true;
ProtectHome = true;
Restart = "on-failure";
RestartSec = "5s";
};
};
};
meta.maintainers = with lib.maintainers; [ malte-v ];
}
|