]> Git — Sourcephile - sourcephile-nix.git/blob - machines/losurdo/networking/tor.nix
tor: preparation
[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 ];
7
8 systemd.services.tor.serviceConfig.StateDirectory = [
9 "tor"
10 "tor/onion"
11 "tor/onion/${networking.domain}"
12 ];
13 systemd.services.tor.serviceConfig.StateDirectoryMode = "0700";
14 services.tor = {
15 enable = true;
16 enableGeoIP = false;
17 hiddenServices = {
18 "${networking.domain}/${networking.hostName}".map = [
19 { port = 22; }
20 ];
21 };
22 extraConfig = ''
23 ClientUseIPv4 1
24 ClientUseIPv6 1
25 ClientPreferIPv6ORPort 0
26 '';
27 };
28 /*
29 # copy your onion folder
30 boot.initrd.secrets = {
31 "/etc/tor/onion/bootup" = /home/tony/tor/onion; # maybe find a better spot to store this.
32 };
33
34 # copy tor to you initrd
35 boot.initrd.extraUtilsCommands = ''
36 copy_bin_and_libs ${pkgs.tor}/bin/tor
37 '';
38
39 # start tor during boot process
40 boot.initrd.network.postCommands = let
41 torRc = (pkgs.writeText "tor.rc" ''
42 DataDirectory /etc/tor
43 SOCKSPort 127.0.0.1:9050 IsolateDestAddr
44 SOCKSPort 127.0.0.1:9063
45 HiddenServiceDir /etc/tor/onion/bootup
46 HiddenServicePort 22 127.0.0.1:22
47 '');
48 in ''
49 echo "tor: preparing onion folder"
50 # have to do this otherwise tor does not want to start
51 chmod -R 700 /etc/tor
52
53 echo "make sure localhost is up"
54 ip a a 127.0.0.1/8 dev lo
55 ip link set lo up
56
57 echo "tor: starting tor"
58 tor -f ${torRc} --verify-config
59 tor -f ${torRc} &
60 '';
61 */
62 }