]> Git — Sourcephile - sourcephile-nix.git/blob - machines/losurdo/networking/tor.nix
nix: update to latest nixpkgs-unstable
[sourcephile-nix.git] / machines / losurdo / networking / tor.nix
1 { pkgs, lib, config, ... }:
2 let inherit (config) networking; in
3 {
4 environment.systemPackages = [
5 pkgs.tor
6 pkgs.pythonPackages.stem
7 pkgs.nyx
8 ];
9
10 systemd.services.tor-init.script = ''
11 install -d -m 700 -o tor -g tor /var/lib/tor/onion/${networking.domain}
12 '';
13 /*
14 systemd.services.tor.serviceConfig.StateDirectory = [
15 "tor"
16 "tor/onion"
17 "tor/onion/${networking.domain}"
18 ];
19 */
20 systemd.services.tor.serviceConfig.StateDirectoryMode = "0700";
21 services.tor = {
22 enable = true;
23 enableGeoIP = false;
24 controlSocket.enable = true;
25 relay.enable = true;
26 relay.role = "private-bridge";
27 relay.port = 443;
28 hiddenServices = {
29 "${networking.domain}/${networking.hostName}".map = [
30 { port = 22; }
31 ];
32 };
33 extraConfig = ''
34 ClientUseIPv4 1
35 ClientUseIPv6 1
36 ClientPreferIPv6ORPort 0
37 '';
38 };
39 /*
40 # copy your onion folder
41 boot.initrd.secrets = {
42 "/etc/tor/onion/bootup" = /home/tony/tor/onion; # maybe find a better spot to store this.
43 };
44
45 # copy tor to you initrd
46 boot.initrd.extraUtilsCommands = ''
47 copy_bin_and_libs ${pkgs.tor}/bin/tor
48 '';
49
50 # start tor during boot process
51 boot.initrd.network.postCommands = let
52 torRc = (pkgs.writeText "tor.rc" ''
53 DataDirectory /etc/tor
54 SOCKSPort 127.0.0.1:9050 IsolateDestAddr
55 SOCKSPort 127.0.0.1:9063
56 HiddenServiceDir /etc/tor/onion/bootup
57 HiddenServicePort 22 127.0.0.1:22
58 '');
59 in ''
60 echo "tor: preparing onion folder"
61 # have to do this otherwise tor does not want to start
62 chmod -R 700 /etc/tor
63
64 echo "make sure localhost is up"
65 ip a a 127.0.0.1/8 dev lo
66 ip link set lo up
67
68 echo "tor: starting tor"
69 tor -f ${torRc} --verify-config
70 tor -f ${torRc} &
71 '';
72 */
73 }