2023-08-06 22:08:38 +02:00
|
|
|
{ config, pkgs, ... }: {
|
2023-08-06 00:45:08 +02:00
|
|
|
services.tor = {
|
|
|
|
enable = true;
|
|
|
|
openFirewall = true;
|
|
|
|
relay = {
|
|
|
|
enable = true;
|
|
|
|
role = "exit";
|
|
|
|
};
|
|
|
|
settings = {
|
|
|
|
ContactInfo = "admin@caspervk.net";
|
|
|
|
DirPort = 80;
|
2023-08-06 22:08:38 +02:00
|
|
|
ORPort =
|
|
|
|
# TOR requires each IPv6 address to be configured explicity
|
|
|
|
let
|
|
|
|
interfaces = builtins.attrValues config.networking.interfaces;
|
|
|
|
ipv6Addresses = pkgs.lib.lists.flatten (map (interface: interface.ipv6.addresses) interfaces);
|
|
|
|
ipv6Ports = map
|
|
|
|
(a: {
|
|
|
|
addr = "[${a.address}]";
|
|
|
|
port = 443;
|
|
|
|
})
|
|
|
|
ipv6Addresses;
|
|
|
|
in
|
|
|
|
[
|
|
|
|
443
|
|
|
|
] ++ ipv6Ports;
|
2023-08-06 00:45:08 +02:00
|
|
|
ControlPort = 9051;
|
|
|
|
DirPortFrontPage = builtins.toFile "tor-exit-notice.html" (builtins.readFile ./tor-exit-notice.html);
|
|
|
|
ExitRelay = true;
|
|
|
|
ExitPolicy = [
|
|
|
|
"reject *:25"
|
|
|
|
"accept *:*"
|
|
|
|
];
|
|
|
|
IPv6Exit = true;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
environment.systemPackages = with pkgs; [
|
2023-08-06 22:08:38 +02:00
|
|
|
nyx # Command-line monitor for Tor
|
2023-08-06 00:45:08 +02:00
|
|
|
];
|
|
|
|
|
|
|
|
environment.persistence."/nix/persist" = {
|
|
|
|
directories = [
|
|
|
|
{ directory = "/var/lib/tor/keys"; user = "tor"; group = "tor"; mode = "0700"; }
|
|
|
|
];
|
|
|
|
};
|
|
|
|
}
|