1 { pkgs, lib, config, ... }:
2 let inherit (config) networking; in
4 environment.systemPackages = [
8 systemd.services.tor.serviceConfig.StateDirectory = [
11 "tor/onion/${networking.domain}"
13 systemd.services.tor.serviceConfig.StateDirectoryMode = "0700";
18 "${networking.domain}/${networking.hostName}".map = [
25 ClientPreferIPv6ORPort 0
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.
34 # copy tor to you initrd
35 boot.initrd.extraUtilsCommands = ''
36 copy_bin_and_libs ${pkgs.tor}/bin/tor
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
49 echo "tor: preparing onion folder"
50 # have to do this otherwise tor does not want to start
53 echo "make sure localhost is up"
54 ip a a 127.0.0.1/8 dev lo
57 echo "tor: starting tor"
58 tor -f ${torRc} --verify-config