Self-host your own digital island

deal with system not in wireguard hosts

Changed files
+9 -3
modules
wireguard
+9 -3
modules/wireguard/default.nix
···
enable = mkEnableOption "wireguard";
server = mkOption {
type = with types; bool;
-
default = cfg.hosts.${config.networking.hostName}.server;
+
default =
+
if cfg.hosts ? config.networking.hostName then
+
cfg.hosts.${config.networking.hostName}.server
+
else false;
};
hosts =
let hostOps = { ... }: {
···
wireguard = {
enable = true;
interfaces.wg0 = let hostName = config.networking.hostName; in {
-
ips = [ "${cfg.hosts."${hostName}".ip}/24" ];
-
listenPort = 51820;
+
ips =
+
if cfg.hosts ? hostname then
+
[ "${cfg.hosts."${hostName}".ip}/24" ]
+
else [ ];
+
listenPort = 51820;
privateKeyFile = "${config.eilean.secretsDir}/wireguard-key-${hostName}";
peers =
let