1 { config, pkgs, lib, ... }:
8 enable = mkEnableOption "toxvpn running on startup";
12 default = "10.123.123.1";
13 description = "your ip on the vpn";
19 description = "udp port for toxcore, port-forward to help with connectivity if you run many nodes behind one NAT";
22 auto_add_peers = mkOption {
23 type = types.listOf types.str;
25 example = [ "toxid1" "toxid2" ];
26 description = "peers to automatically connect to on startup";
31 config = mkIf config.services.toxvpn.enable {
32 systemd.services.toxvpn = {
33 description = "toxvpn daemon";
35 wantedBy = [ "multi-user.target" ];
36 after = [ "network.target" ];
39 mkdir -p /run/toxvpn || true
40 chown toxvpn /run/toxvpn
43 path = [ pkgs.toxvpn ];
46 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}
51 Restart = "on-success";
55 restartIfChanged = false; # Likely to be used for remote admin
58 environment.systemPackages = [ pkgs.toxvpn ];
64 home = "/var/lib/toxvpn";
68 users.groups.toxvpn = {};