From f950d3c26be0c4b13e95b16cbb0902ea36f74792 Mon Sep 17 00:00:00 2001 From: Sean Buckley Date: Sun, 9 Oct 2022 15:02:53 -0400 Subject: [PATCH] levi: add wireguard --- hosts/levi/default.nix | 2 +- modules/wg-home.nix | 20 ++++++++++++++++---- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/hosts/levi/default.nix b/hosts/levi/default.nix index 6fb7f4d..3afc7fc 100644 --- a/hosts/levi/default.nix +++ b/hosts/levi/default.nix @@ -37,7 +37,7 @@ in profile = "desktop"; gaming.enable = true; horizon.enable = true; - wg-home.enable = true; + wg-home = { enable = true; path = "${persist}/wireguard_home.conf"; }; }; boot = { diff --git a/modules/wg-home.nix b/modules/wg-home.nix index acc9c45..ace6d10 100644 --- a/modules/wg-home.nix +++ b/modules/wg-home.nix @@ -1,11 +1,23 @@ { config, lib, pkgs, ... }: +let + cfg = config.sconfig.wg-home; +in { - options.sconfig.wg-home.enable = lib.mkEnableOption "set up home VPN"; + options.sconfig.wg-home = { - config = lib.mkIf config.sconfig.wg-home.enable { + 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 /var/lib/nixos/wireguard_home.conf"; - preStop = "wg-quick down /var/lib/nixos/wireguard_home.conf"; + script = "wg-quick up ${cfg.path}"; + preStop = "wg-quick down ${cfg.path}"; path = [ pkgs.wireguard-tools ]; serviceConfig = { type = "oneshot";