From bb16bced36be4f61d19c7472ecb14949eb2d6914 Mon Sep 17 00:00:00 2001 From: michael bishop <cleverca22@gmail.com> Date: Sun, 25 Jun 2017 20:17:20 -0300 Subject: [PATCH] toxvpn: 20161230 -> 2017-06-25 --- nixos/modules/services/networking/toxvpn.nix | 16 ++++++++++++- pkgs/tools/networking/toxvpn/default.nix | 25 +++++++++++++------- 2 files changed, 31 insertions(+), 10 deletions(-) diff --git a/nixos/modules/services/networking/toxvpn.nix b/nixos/modules/services/networking/toxvpn.nix index 911836fdee42..5e13402d7645 100644 --- a/nixos/modules/services/networking/toxvpn.nix +++ b/nixos/modules/services/networking/toxvpn.nix @@ -18,6 +18,13 @@ with lib; default = 33445; description = "udp port for toxcore, port-forward to help with connectivity if you run many nodes behind one NAT"; }; + + auto_add_peers = mkOption { + type = types.listOf types.string; + default = []; + example = ''[ "toxid1" "toxid2" ]''; + description = "peers to automacally connect to on startup"; + }; }; }; @@ -33,8 +40,13 @@ with lib; chown toxvpn /run/toxvpn ''; + path = [ pkgs.toxvpn ]; + + script = '' + exec toxvpn -i ${config.services.toxvpn.localip} -l /run/toxvpn/control -u toxvpn -p ${toString config.services.toxvpn.port} ${lib.concatMapStringsSep " " (x: "-a ${x}") config.services.toxvpn.auto_add_peers} + ''; + serviceConfig = { - ExecStart = "${pkgs.toxvpn}/bin/toxvpn -i ${config.services.toxvpn.localip} -l /run/toxvpn/control -u toxvpn -p ${toString config.services.toxvpn.port}"; KillMode = "process"; Restart = "on-success"; Type = "notify"; @@ -43,6 +55,8 @@ with lib; restartIfChanged = false; # Likely to be used for remote admin }; + environment.systemPackages = [ pkgs.toxvpn ]; + users.extraUsers = { toxvpn = { uid = config.ids.uids.toxvpn; diff --git a/pkgs/tools/networking/toxvpn/default.nix b/pkgs/tools/networking/toxvpn/default.nix index 05e833f2f8ef..c7fa1c7a2719 100644 --- a/pkgs/tools/networking/toxvpn/default.nix +++ b/pkgs/tools/networking/toxvpn/default.nix @@ -1,29 +1,36 @@ -{ stdenv, fetchFromGitHub, cmake, lib -, libtoxcore, jsoncpp, libsodium, systemd, libcap }: +{ stdenv, fetchFromGitHub, cmake, nlohmann_json, +libtoxcore, libsodium, systemd, libcap, zeromq }: -with lib; +with stdenv.lib; -stdenv.mkDerivation rec { +let + systemdOrNull = if stdenv.system == "x86_64-darwin" then null else systemd; + if_systemd = optional (systemdOrNull != null); +in stdenv.mkDerivation rec { name = "toxvpn-${version}"; - version = "20161230"; + version = "2017-06-25"; src = fetchFromGitHub { owner = "cleverca22"; repo = "toxvpn"; - rev = "4b7498a5fae680484cb5779ac01fb08ad3089bdd"; - sha256 = "0bazdspiym9xyzms7pd6i1f2gph13rnf764nm3jc27fbfwmc98rp"; + rev = "7bd6f169d69c511affa8c9672e8f794e4e205a44"; + sha256 = "1km8hkrxmrnca1b49vbw5kyldayaln5plvz78vhf8325r6c5san0"; }; - buildInputs = [ libtoxcore jsoncpp libsodium libcap ] ++ optional stdenv.isLinux systemd; + buildInputs = [ libtoxcore nlohmann_json libsodium zeromq ] + ++ if_systemd systemd + ++ optional (stdenv.system != "x86_64-darwin") libcap; nativeBuildInputs = [ cmake ]; cmakeFlags = optional stdenv.isLinux [ "-DSYSTEMD=1" ]; + postInstall = "$out/bin/toxvpn -h"; + meta = with stdenv.lib; { description = "A powerful tool that allows one to make tunneled point to point connections over Tox"; homepage = https://github.com/cleverca22/toxvpn; license = licenses.gpl3; maintainers = with maintainers; [ cleverca22 obadz ]; - platforms = platforms.linux; + platforms = platforms.linux ++ platforms.darwin; }; }