33 lines
762 B
Nix
33 lines
762 B
Nix
{
|
|
config,
|
|
lib,
|
|
...
|
|
}: let
|
|
cfg = config.hive.wg.client;
|
|
peers = import ./peers.nix {};
|
|
in {
|
|
options.hive.wg.client = {
|
|
enable = lib.mkEnableOption "Enable WireGuard client";
|
|
autoConnect = lib.mkOption {
|
|
type = lib.types.bool;
|
|
default = false;
|
|
description = "Automatically connect to the WireGuard server with systemd";
|
|
};
|
|
privateKeyFile = lib.mkOption {
|
|
type = lib.types.path;
|
|
description = "Path to the private key file for the WireGuard client";
|
|
};
|
|
};
|
|
|
|
config = lib.mkIf cfg.enable {
|
|
networking.wg-quick.interfaces.wg0 = {
|
|
inherit (peers.jonas) address;
|
|
inherit (cfg) privateKeyFile;
|
|
autostart = cfg.autoConnect;
|
|
peers = [
|
|
peers.harbor
|
|
];
|
|
};
|
|
};
|
|
}
|