mirror of
https://github.com/buckley310/nixos-config.git
synced 2024-11-09 18:47:02 +00:00
35 lines
681 B
Nix
35 lines
681 B
Nix
{
|
|
config,
|
|
lib,
|
|
pkgs,
|
|
...
|
|
}:
|
|
let
|
|
cfg = config.sconfig.wg-home;
|
|
in
|
|
{
|
|
options.sconfig.wg-home = {
|
|
|
|
enable = lib.mkEnableOption "set up home VPN";
|
|
|
|
path = lib.mkOption {
|
|
type = lib.types.path;
|
|
default = "/var/lib/nixos/wireguard_home.conf";
|
|
};
|
|
|
|
};
|
|
|
|
config = lib.mkIf cfg.enable {
|
|
systemd.services.wg-home = {
|
|
script = "wg-quick up ${cfg.path}";
|
|
preStop = "wg-quick down ${cfg.path}";
|
|
path = [ pkgs.wireguard-tools ];
|
|
serviceConfig = {
|
|
type = "oneshot";
|
|
RemainAfterExit = true;
|
|
};
|
|
};
|
|
boot.kernelModules = [ "wireguard" ];
|
|
environment.systemPackages = [ pkgs.wireguard-tools ];
|
|
};
|
|
}
|