{ 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" ]; privateKeyFile = config.sops.secrets."${service.name}/mars-private".path; }; }; }; sops = let sopsPath = secret: { path = "${service.sops.path0}/${service.name}-${secret}"; owner = "root"; mode = "600"; }; in { secrets = builtins.listToAttrs ( map (secret: { name = "${service.name}/${secret}"; value = sopsPath secret; }) [ "mars-private" "mars-public" ] ); }; }