about summary refs log tree commit diff
path: root/nixos
diff options
context:
space:
mode:
authorIsabelle <hi@f2k1.de>2024-05-23 13:53:45 +0200
committerGitHub <noreply@github.com>2024-05-23 13:53:45 +0200
commit56141e2236e2607f3e54858a9617b2eb8b4adee8 (patch)
tree917514083ce8856f7fdfe606748efd42c97d0867 /nixos
parentdc2ac5f4eab2600e3179d5c0ea57f09ce1f4c4dd (diff)
nixos/wireguard: add option preShutdown for commands called before interface deletion (#310345)
Diffstat (limited to 'nixos')
-rw-r--r--nixos/modules/services/networking/wireguard.nix10
1 files changed, 10 insertions, 0 deletions
diff --git a/nixos/modules/services/networking/wireguard.nix b/nixos/modules/services/networking/wireguard.nix
index 3f68af3a86c96..81abae2c9303d 100644
--- a/nixos/modules/services/networking/wireguard.nix
+++ b/nixos/modules/services/networking/wireguard.nix
@@ -80,6 +80,15 @@ let
         description = "Commands called at the end of the interface setup.";
       };
 
+      preShutdown = mkOption {
+        example = literalExpression ''"''${pkgs.iproute2}/bin/ip netns del foo"'';
+        default = "";
+        type = with types; coercedTo (listOf str) (concatStringsSep "\n") lines;
+        description = ''
+          Commands called before shutting down the interface.
+        '';
+      };
+
       postShutdown = mkOption {
         example = literalExpression ''"''${pkgs.openresolv}/bin/resolvconf -d wg0"'';
         default = "";
@@ -497,6 +506,7 @@ let
         '';
 
         postStop = ''
+          ${values.preShutdown}
           ${ipPostMove} link del dev "${name}"
           ${values.postShutdown}
         '';