2025-03-29 23:08:26 -05:00
|
|
|
{
|
|
|
|
flake,
|
|
|
|
lib,
|
|
|
|
config,
|
|
|
|
...
|
|
|
|
}:
|
|
|
|
let
|
2025-07-01 12:40:17 -05:00
|
|
|
inherit (flake.config.machines.devices) ceres mars;
|
2025-03-29 23:08:26 -05:00
|
|
|
inherit (flake.config.services.instances) searx web;
|
2025-07-01 04:11:32 -05:00
|
|
|
configHelpers = {
|
|
|
|
service = searx;
|
|
|
|
hostname = config.networking.hostName;
|
|
|
|
localhost = web.localhost.address0;
|
|
|
|
host = configHelpers.service.domains.url0;
|
|
|
|
};
|
|
|
|
configPath = ./config;
|
|
|
|
configImports = {
|
|
|
|
general = import (configPath + /general.nix);
|
|
|
|
ui = import (configPath + /ui.nix);
|
|
|
|
search = import (configPath + /search.nix);
|
|
|
|
server = import (configPath + /server.nix) { inherit config flake configHelpers; };
|
|
|
|
engines = import (configPath + /engines.nix) { inherit lib; };
|
|
|
|
outgoing = import (configPath + /outgoing.nix);
|
|
|
|
enabled_plugins = import (configPath + /plugins.nix);
|
|
|
|
};
|
|
|
|
|
2025-03-29 23:08:26 -05:00
|
|
|
in
|
|
|
|
{
|
|
|
|
services =
|
|
|
|
{
|
|
|
|
searx = {
|
|
|
|
enable = true;
|
|
|
|
redisCreateLocally = true;
|
|
|
|
uwsgiConfig = {
|
|
|
|
socket = "/run/searx/searx.sock";
|
2025-07-01 04:11:32 -05:00
|
|
|
http = ":${builtins.toString configHelpers.service.ports.port0}";
|
2025-03-29 23:08:26 -05:00
|
|
|
chmod-socket = "660";
|
|
|
|
};
|
2025-07-01 04:11:32 -05:00
|
|
|
settings = configImports;
|
2025-03-29 23:08:26 -05:00
|
|
|
};
|
|
|
|
}
|
|
|
|
// (
|
2025-07-01 04:11:32 -05:00
|
|
|
if configHelpers.hostname == ceres.name then
|
2025-03-29 23:08:26 -05:00
|
|
|
{
|
|
|
|
caddy = {
|
|
|
|
virtualHosts = {
|
2025-07-01 04:11:32 -05:00
|
|
|
"${configHelpers.host}" = {
|
2025-03-29 23:08:26 -05:00
|
|
|
extraConfig = ''
|
2025-07-01 05:32:55 -05:00
|
|
|
@allowed_ips {
|
2025-07-01 12:46:52 -05:00
|
|
|
remote_ip ${mars.wireguard.ip0}
|
|
|
|
}
|
|
|
|
handle @allowed_ips {
|
|
|
|
reverse_proxy unix//run/searx/searx.sock
|
|
|
|
}
|
|
|
|
handle {
|
|
|
|
respond "Access Denied" 403
|
|
|
|
}
|
2025-07-01 05:32:55 -05:00
|
|
|
tls ${configHelpers.service.ssl.cert} ${configHelpers.service.ssl.key}
|
2025-03-29 23:08:26 -05:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{ }
|
|
|
|
);
|
|
|
|
|
|
|
|
users.groups.searx.members = [ "caddy" ];
|
|
|
|
# systemd.services.caddy.serviceConfig.ProtectHome = false;
|
|
|
|
|
|
|
|
sops =
|
|
|
|
let
|
|
|
|
sopsPath = secret: {
|
2025-07-01 04:11:32 -05:00
|
|
|
path = "${configHelpers.service.sops.path0}/${configHelpers.service.name}-${secret}";
|
|
|
|
owner = configHelpers.service.name;
|
2025-03-29 23:08:26 -05:00
|
|
|
mode = "600";
|
|
|
|
};
|
|
|
|
in
|
|
|
|
{
|
|
|
|
secrets = builtins.listToAttrs (
|
|
|
|
map
|
|
|
|
(secret: {
|
2025-07-01 04:11:32 -05:00
|
|
|
name = "${configHelpers.service.name}-${secret}";
|
2025-03-29 23:08:26 -05:00
|
|
|
value = sopsPath secret;
|
|
|
|
})
|
|
|
|
[
|
|
|
|
"key"
|
|
|
|
]
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
networking = {
|
|
|
|
firewall = {
|
2025-07-01 04:32:00 -05:00
|
|
|
interfaces.wg0.allowedTCPPorts = [
|
2025-07-01 04:11:32 -05:00
|
|
|
configHelpers.service.ports.port0
|
2025-03-29 23:08:26 -05:00
|
|
|
];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|