Skip to content

Commit c6ea892

Browse files
authored
nixos/websurfx: init module (#471684)
2 parents 115098b + b99f23b commit c6ea892

2 files changed

Lines changed: 116 additions & 0 deletions

File tree

nixos/modules/module-list.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1780,6 +1780,7 @@
17801780
./services/web-apps/vikunja.nix
17811781
./services/web-apps/wakapi.nix
17821782
./services/web-apps/weblate.nix
1783+
./services/web-apps/websurfx.nix
17831784
./services/web-apps/whitebophir.nix
17841785
./services/web-apps/whoami.nix
17851786
./services/web-apps/wiki-js.nix
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
{
2+
config,
3+
lib,
4+
pkgs,
5+
...
6+
}:
7+
8+
let
9+
cfg = config.services.websurfx;
10+
settingsFormat = pkgs.formats.lua { asBindings = true; };
11+
settingsFile = settingsFormat.generate "config.lua" cfg.settings;
12+
in
13+
{
14+
options = {
15+
services.websurfx = {
16+
enable = lib.mkEnableOption "Websurfx, a metasearch engine";
17+
package = lib.mkPackageOption pkgs "websurfx" { };
18+
openFirewall = lib.mkEnableOption "Whether to open the used port in the firewall";
19+
settings = lib.mkOption {
20+
type = lib.types.submodule {
21+
freeformType = settingsFormat.type;
22+
23+
options.binding_ip = lib.mkOption {
24+
type = lib.types.str;
25+
default = "127.0.0.1";
26+
description = "IP address on which the server should be launched";
27+
};
28+
options.port = lib.mkOption {
29+
type = lib.types.port;
30+
default = 4567;
31+
description = "Port on which the server should be launched";
32+
};
33+
};
34+
default = { };
35+
description = ''
36+
Configuration options for Websurfx, see
37+
[websurfx/config.lua](https://github.com/neon-mmd/websurfx/blob/rolling/websurfx/config.lua)
38+
for supported values.
39+
'';
40+
};
41+
};
42+
};
43+
44+
config = lib.mkIf cfg.enable {
45+
services.websurfx.settings = {
46+
# General
47+
logging = lib.mkDefault true;
48+
debug = lib.mkDefault false;
49+
threads = lib.mkDefault 10;
50+
51+
# Server
52+
production_use = lib.mkDefault false;
53+
request_timeout = lib.mkDefault 30;
54+
tcp_connection_keep_alive = lib.mkDefault 30;
55+
pool_idle_connection_timeout = lib.mkDefault 30;
56+
rate_limiter = {
57+
number_of_requests = lib.mkDefault 20;
58+
time_limit = lib.mkDefault 3;
59+
};
60+
https_adaptive_window_size = lib.mkDefault true;
61+
62+
operating_system_tls_certificates = lib.mkDefault true;
63+
64+
number_of_https_connections = lib.mkDefault 10;
65+
client_connection_keep_alive = lib.mkDefault 120;
66+
67+
# Search
68+
safe_search = lib.mkDefault 2;
69+
70+
# Website
71+
colorscheme = lib.mkDefault "catppuccin-mocha";
72+
theme = lib.mkDefault "simple";
73+
animation = lib.mkDefault "simple-frosted-glow";
74+
75+
# Caching
76+
#redis_url = "redis://127.0.0.1:8082"; # The nixpkgs build doesn't have the redis-cache feature enabled
77+
cache_expiry_time = lib.mkDefault 600;
78+
79+
# Search Engines
80+
upstream_search_engines = {
81+
DuckDuckGo = lib.mkDefault true;
82+
Searx = lib.mkDefault false;
83+
Brave = lib.mkDefault false;
84+
Startpage = lib.mkDefault false;
85+
LibreX = lib.mkDefault false;
86+
Mojeek = lib.mkDefault false;
87+
Bing = lib.mkDefault false;
88+
Wikipedia = lib.mkDefault true;
89+
Yahoo = lib.mkDefault false;
90+
};
91+
92+
proxy = lib.mkDefault null;
93+
};
94+
95+
networking.firewall.allowedTCPPorts = lib.mkIf cfg.openFirewall [ cfg.settings.port ];
96+
97+
systemd.services.websurfx = {
98+
description = "Websurfx, a metasearch engine";
99+
100+
serviceConfig = {
101+
ExecStart = lib.getExe cfg.package;
102+
DynamicUser = true;
103+
RuntimeDirectory = "websurfx";
104+
Environment = [ "HOME=%t/websurfx" ];
105+
BindReadOnlyPaths = [ "${settingsFile}:%t/websurfx/.config/websurfx/config.lua" ];
106+
};
107+
108+
wants = [ "network-online.target" ];
109+
after = [ "network-online.target" ];
110+
wantedBy = [ "multi-user.target" ];
111+
};
112+
};
113+
114+
meta.maintainers = [ lib.maintainers.SchweGELBin ];
115+
}

0 commit comments

Comments
 (0)