dotfiles/systems/mars/config/wireguard.nix

39 lines
812 B
Nix
Raw Normal View History

2025-10-01 19:51:55 -05:00
{ config, flake, ... }:
let
inherit (flake.config.services.instances) wireGuard;
inherit (flake.config.machines.devices) mars;
service = wireGuard;
in
{
networking = {
wireguard.interfaces = {
wg0 = {
ips = [ "${mars.wireguard.ip0}/32" ];
2025-11-28 20:35:50 -06:00
privateKeyFile = config.sops.secrets."${service.name}/mars-private".path;
2025-10-01 19:51:55 -05:00
};
};
};
sops =
let
sopsPath = secret: {
2025-11-28 20:35:50 -06:00
path = "${service.sops.path0}/${service.name}-${secret}";
2025-10-01 19:51:55 -05:00
owner = "root";
mode = "600";
};
in
{
secrets = builtins.listToAttrs (
map
(secret: {
2025-11-28 20:35:50 -06:00
name = "${service.name}/${secret}";
2025-10-01 19:51:55 -05:00
value = sopsPath secret;
})
[
"mars-private"
"mars-public"
]
);
};
}