summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--custom/tinc/def.nix24
1 files changed, 24 insertions, 0 deletions
diff --git a/custom/tinc/def.nix b/custom/tinc/def.nix
index 5d1216c9..0fa0b912 100644
--- a/custom/tinc/def.nix
+++ b/custom/tinc/def.nix
@@ -76,6 +76,15 @@ let
76 ''; 76 '';
77 }; 77 };
78 78
79 nmDispatch = mkOption {
80 type = types.bool;
81 default = config.networking.networkmanager.enable;
82 description = ''
83 Install a network-manager dispatcher script to automatically
84 connect to all remotes when networking is available
85 '';
86 };
87
79 }; 88 };
80in 89in
81 90
@@ -134,6 +143,21 @@ in
134 } // data.interfaceConfig) 143 } // data.interfaceConfig)
135 ); 144 );
136 145
146 networking.networkmanager.dispatcherScripts = flip mapAttrs' cfg.networks (network: data: optional data.nmDispatch {
147 type = "basic";
148 source = pkgs.writeScript "connectRemotes.sh" ''
149 #!${pkgs.stdenv.shell}
150
151 shopt -s extglob
152
153 case "''${2}" in
154 (?(vpn-)up)
155 systemctl --signal=ALRM --kill-who=main kill "tinc.${network}.service"
156 ;;
157 esac
158 '';
159 });
160
137 systemd.services = flip mapAttrs' cfg.networks (network: data: nameValuePair 161 systemd.services = flip mapAttrs' cfg.networks (network: data: nameValuePair
138 ("tinc.${network}") 162 ("tinc.${network}")
139 ({ 163 ({