git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #93538 from erictapen/tinc-rsa-key-file

nixos/tinc: allow configuration of RSA private key file

commit89e0d97d7e364b111c3bb4efa8609ca0249f9fc7 authorxeji <36407913+xeji@users.noreply.github.com> dateSat 1 Aug 2020, 23:32 (6 years ago) parent2dee11d1192255
1 file changed+14−2
nixos/modules/services/networking/tinc.nix+14−2
nixos/modules/services/networking/tinc.nix+14−2
@@ -48,6 +48,14 @@ in
4848 '';
4949 };
5050
51+ rsaPrivateKeyFile = mkOption {
52+ default = null;
53+ type = types.nullOr types.path;
54+ description = ''
55+ Path of the private RSA keyfile.
56+ '';
57+ };
58+
5159 debugLevel = mkOption {
5260 default = 0;
5361 type = types.addCheck types.int (l: l >= 0 && l <= 5);
@@ -139,6 +147,7 @@ in
139147 Name = ${if data.name == null then "$HOST" else data.name}
140148 DeviceType = ${data.interfaceType}
141149 ${optionalString (data.ed25519PrivateKeyFile != null) "Ed25519PrivateKeyFile = ${data.ed25519PrivateKeyFile}"}
150+ ${optionalString (data.rsaPrivateKeyFile != null) "PrivateKeyFile = ${data.rsaPrivateKeyFile}"}
142151 ${optionalString (data.listenAddress != null) "ListenAddress = ${data.listenAddress}"}
143152 ${optionalString (data.bindToAddress != null) "BindToAddress = ${data.bindToAddress}"}
144153 Interface = tinc.${network}
@@ -170,12 +179,15 @@ in
170179 # Determine how we should generate our keys
171180 if type tinc >/dev/null 2>&1; then
172181 # Tinc 1.1+ uses the tinc helper application for key generation
173− ${if data.ed25519PrivateKeyFile != null then " # Keyfile managed by nix" else ''
182+ ${if data.ed25519PrivateKeyFile != null then " # ed25519 Keyfile managed by nix" else ''
174183 # Prefer ED25519 keys (only in 1.1+)
175184 [ -f "/etc/tinc/${network}/ed25519_key.priv" ] || tinc -n ${network} generate-ed25519-keys
176185 ''}
177− # Otherwise use RSA keys
186+ ${if data.rsaPrivateKeyFile != null then " # RSA Keyfile managed by nix" else ''
178187 [ -f "/etc/tinc/${network}/rsa_key.priv" ] || tinc -n ${network} generate-rsa-keys 4096
188+ ''}
189+ # In case there isn't anything to do
190+ true
179191 else
180192 # Tinc 1.0 uses the tincd application
181193 [ -f "/etc/tinc/${network}/rsa_key.priv" ] || tincd -n ${network} -K 4096