summary refs log tree commit diff
path: root/nixos/modules/services/networking
diff options
context:
space:
mode:
authorgin66 <5549373+gin66@users.noreply.github.com>2022-02-07 16:46:51 +0100
committerGitHub <noreply@github.com>2022-02-07 16:46:51 +0100
commitcb648f080dba0fd0b953686c43b0ce05d0ed9ef2 (patch)
tree23e4c54a6fc8407b5b37031f98cec0b8d9b0f9a1 /nixos/modules/services/networking
parentfa286ff843a694d9b2025f1e646c1db6ab56d509 (diff)
downloadnixpkgs-cb648f080dba0fd0b953686c43b0ce05d0ed9ef2.tar
nixpkgs-cb648f080dba0fd0b953686c43b0ce05d0ed9ef2.tar.gz
nixpkgs-cb648f080dba0fd0b953686c43b0ce05d0ed9ef2.tar.bz2
nixpkgs-cb648f080dba0fd0b953686c43b0ce05d0ed9ef2.tar.lz
nixpkgs-cb648f080dba0fd0b953686c43b0ce05d0ed9ef2.tar.xz
nixpkgs-cb648f080dba0fd0b953686c43b0ce05d0ed9ef2.tar.zst
nixpkgs-cb648f080dba0fd0b953686c43b0ce05d0ed9ef2.zip
wg-netmanager: init at 0.3.6 (#155149)
Co-authored-by: Sandro <sandro.jaeckel@gmail.com>
Diffstat (limited to 'nixos/modules/services/networking')
-rw-r--r--nixos/modules/services/networking/wg-netmanager.nix42
1 files changed, 42 insertions, 0 deletions
diff --git a/nixos/modules/services/networking/wg-netmanager.nix b/nixos/modules/services/networking/wg-netmanager.nix
new file mode 100644
index 00000000000..493ff7ceba9
--- /dev/null
+++ b/nixos/modules/services/networking/wg-netmanager.nix
@@ -0,0 +1,42 @@
+{ config, lib, pkgs, ... }:
+
+with lib;
+
+let
+  cfg = config.services.wg-netmanager;
+in
+{
+
+  options = {
+    services.wg-netmanager = {
+      enable = mkEnableOption "Wireguard network manager";
+    };
+  };
+
+  ###### implementation
+  config = mkIf cfg.enable {
+    # NOTE: wg-netmanager runs as root
+    systemd.services.wg-netmanager = {
+      description = "Wireguard network manager";
+      wantedBy = [ "multi-user.target" ];
+      after = [ "network.target" ];
+      path = with pkgs; [ wireguard-tools iproute2 wireguard-go ];
+      serviceConfig = {
+        Type = "simple";
+        Restart = "on-failure";
+        ExecStart = "${pkgs.wg-netmanager}/bin/wg_netmanager";
+        ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID";
+        ExecStop = "${pkgs.coreutils}/bin/kill -HUP $MAINPID";
+
+        ReadWritePaths = [
+          "/tmp"  # wg-netmanager creates files in /tmp before deleting them after use
+        ];
+      };
+      unitConfig =  {
+        ConditionPathExists = ["/etc/wg_netmanager/network.yaml" "/etc/wg_netmanager/peer.yaml"];
+      };
+    };
+  };
+
+  meta.maintainers = with maintainers; [ gin66 ];
+}