2025-07-01 04:11:32 -05:00
|
|
|
{ config, flake, ... }:
|
|
|
|
let
|
|
|
|
inherit (flake.config.services.instances) wireGuard web;
|
2025-07-01 13:54:00 -05:00
|
|
|
inherit (flake.config.machines.devices) ceres mars;
|
2025-07-01 04:11:32 -05:00
|
|
|
service = wireGuard;
|
|
|
|
in
|
|
|
|
{
|
|
|
|
networking = {
|
2025-07-01 14:14:51 -05:00
|
|
|
wireguard.interfaces = {
|
|
|
|
wg0 = {
|
2025-07-01 14:51:22 -05:00
|
|
|
ips = [ "${mars.wireguard.ip0}/24" ];
|
2025-07-01 14:14:51 -05:00
|
|
|
privateKeyFile = config.sops.secrets."${service.name}-mars-private".path;
|
|
|
|
peers = [
|
|
|
|
{
|
|
|
|
publicKey = "fs58+Kz+eG9qAXvvMB2NkW+wa88yP61uam4HHWaBJVw=";
|
|
|
|
allowedIPs = [
|
|
|
|
"${ceres.wireguard.ip0}/32"
|
|
|
|
"192.168.1.0/24"
|
|
|
|
];
|
|
|
|
endpoint = "${web.remotehost.address0}:${builtins.toString service.ports.port1}";
|
|
|
|
persistentKeepalive = 25;
|
|
|
|
}
|
|
|
|
];
|
|
|
|
};
|
2025-07-01 04:11:32 -05:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
sops =
|
|
|
|
let
|
|
|
|
sopsPath = secret: {
|
|
|
|
path = "${service.sops.path0}/${service.name}-${secret}-pass";
|
|
|
|
owner = "root";
|
|
|
|
mode = "600";
|
|
|
|
};
|
|
|
|
in
|
|
|
|
{
|
|
|
|
secrets = builtins.listToAttrs (
|
|
|
|
map
|
|
|
|
(secret: {
|
|
|
|
name = "${service.name}-${secret}";
|
|
|
|
value = sopsPath secret;
|
|
|
|
})
|
|
|
|
[
|
|
|
|
"mars-private"
|
|
|
|
"mars-public"
|
|
|
|
]
|
|
|
|
);
|
|
|
|
};
|
|
|
|
}
|