diff --git a/nixos/modules/services/networking/syncthing.nix b/nixos/modules/services/networking/syncthing.nix index 2d32cf4517062e..f3f30f706b7f42 100644 --- a/nixos/modules/services/networking/syncthing.nix +++ b/nixos/modules/services/networking/syncthing.nix @@ -621,6 +621,21 @@ in { config = mkIf cfg.enable { + vars.generators.syncthing = { + files."cert.pem" = {}; + files."key.pem" = {}; + files."syncthing.pub".secret = false; + runtimeInputs = [ + pkgs.coreutils + pkgs.gnugrep + pkgs.syncthing + ]; + script = '' + syncthing generate --config "$out" + < "$out"/config.xml grep -oP '(?<= "$out"/syncthing.pub + ''; + }; + networking.firewall = mkIf cfg.openDefaultPorts { allowedTCPPorts = [ 22000 ]; allowedUDPPorts = [ 21027 22000 ];