1 { config, lib, pkgs, ... }:
5 cfg = config.services.tor;
7 torify = pkgs.writeTextFile {
10 #!${pkgs.runtimeShell}
11 TSOCKS_CONF_FILE=${pkgs.writeText "tsocks.conf" cfg.tsocks.config} LD_PRELOAD="${pkgs.tsocks}/lib/libtsocks.so $LD_PRELOAD" "$@"
14 destination = "/bin/tsocks";
25 services.tor.tsocks = {
31 Whether to build tsocks wrapper script to relay application traffic via Tor.
34 You shouldn't use this unless you know what you're
35 doing because your installation of Tor already comes with
36 its own superior (doesn't leak DNS queries)
37 `torsocks` wrapper which does pretty much
38 exactly the same thing as this.
45 default = "localhost:9050";
46 example = "192.168.0.20";
48 IP address of TOR client to use.
56 Extra configuration. Contents will be added verbatim to TSocks
67 config = mkIf cfg.tsocks.enable {
69 environment.systemPackages = [ torify ]; # expose it to the users
71 services.tor.tsocks.config = ''
72 server = ${toString(head (splitString ":" cfg.tsocks.server))}
73 server_port = ${toString(tail (splitString ":" cfg.tsocks.server))}
75 local = 127.0.0.0/255.128.0.0
76 local = 127.128.0.0/255.192.0.0