feat: add wireguard, make options with nullOr
This commit is contained in:
@@ -74,7 +74,7 @@ in {
|
|||||||
description = "Enable updns";
|
description = "Enable updns";
|
||||||
};
|
};
|
||||||
key = lib.mkOption {
|
key = lib.mkOption {
|
||||||
type = lib.types.str;
|
type = with types; nullOr str;
|
||||||
example = "example";
|
example = "example";
|
||||||
description = "key for updns";
|
description = "key for updns";
|
||||||
};
|
};
|
||||||
@@ -85,6 +85,11 @@ in {
|
|||||||
default = false;
|
default = false;
|
||||||
description = "Enable VPN";
|
description = "Enable VPN";
|
||||||
};
|
};
|
||||||
|
privateKeyFile = lib.mkOption {
|
||||||
|
type = with types; nullOr str;
|
||||||
|
example = "/private/wireguard_private_key";
|
||||||
|
description = "File pointing to private key as generated by {command}`wg genkey`.";
|
||||||
|
};
|
||||||
clients = mkOption {
|
clients = mkOption {
|
||||||
default = [ ];
|
default = [ ];
|
||||||
description = "VPN Clients";
|
description = "VPN Clients";
|
||||||
@@ -111,7 +116,7 @@ in {
|
|||||||
description = "Network interface for WAN";
|
description = "Network interface for WAN";
|
||||||
};
|
};
|
||||||
internal = lib.mkOption {
|
internal = lib.mkOption {
|
||||||
type = lib.types.str;
|
type = with types; nullOr str;
|
||||||
example = "enp3s0";
|
example = "enp3s0";
|
||||||
description = "Internal network interface";
|
description = "Internal network interface";
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -3,5 +3,6 @@
|
|||||||
./interfaces.nix
|
./interfaces.nix
|
||||||
./dhcp.nix
|
./dhcp.nix
|
||||||
./firewall.nix
|
./firewall.nix
|
||||||
|
./wireguard.nix
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
10
modules/cloonar-assistant/networking/wireguard.nix
Normal file
10
modules/cloonar-assistant/networking/wireguard.nix
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
{ config, lib, ... }: {
|
||||||
|
networking.wireguard.interfaces = lib.mkIf config.cloonar-assistant.vpn.enable {
|
||||||
|
wg_cloonar = {
|
||||||
|
ips = [ "${config.networkPrefix}.98.1/24" ];
|
||||||
|
listenPort = 51820;
|
||||||
|
privateKeyFile = config.cloonar-assistant.vpn.privateKeyFile;
|
||||||
|
peers = config.cloonar-assistant.vpn.clients;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user