diff options
author | Gregor Kleen <gkleen@yggdrasil.li> | 2017-10-28 23:42:44 +0200 |
---|---|---|
committer | Gregor Kleen <gkleen@yggdrasil.li> | 2017-10-28 23:42:44 +0200 |
commit | 663c4110fcb9fd21c9a8134ceb1b48ab3aa45a54 (patch) | |
tree | 0a157ad02f5c7ca13796405f5e8ed540c42e7b86 /custom/tinc | |
parent | 03dbeb75371c701bccddedbe6e8429d6e45e08df (diff) | |
download | nixos-663c4110fcb9fd21c9a8134ceb1b48ab3aa45a54.tar nixos-663c4110fcb9fd21c9a8134ceb1b48ab3aa45a54.tar.gz nixos-663c4110fcb9fd21c9a8134ceb1b48ab3aa45a54.tar.bz2 nixos-663c4110fcb9fd21c9a8134ceb1b48ab3aa45a54.tar.xz nixos-663c4110fcb9fd21c9a8134ceb1b48ab3aa45a54.zip |
tinc nmDispatch
Diffstat (limited to 'custom/tinc')
-rw-r--r-- | custom/tinc/def.nix | 24 |
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 | }; |
80 | in | 89 | in |
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 | ({ |