2024-04-18 18:18:53 +03:00
|
|
|
{ config, pkgs, lib, ... }:
|
2024-04-16 02:51:46 +03:00
|
|
|
|
|
|
|
let
|
|
|
|
cfg = config.local.programs.browsers.tor-browser;
|
|
|
|
|
2024-04-18 18:18:53 +03:00
|
|
|
policiesJson = pkgs.callPackage ./policies.nix { };
|
2024-04-16 02:51:46 +03:00
|
|
|
|
|
|
|
torBrowser = (pkgs.tor-browser-bundle-bin.override {
|
|
|
|
mediaSupport = true;
|
|
|
|
pulseaudioSupport = true;
|
|
|
|
}).overrideAttrs (attrs: {
|
|
|
|
postInstall = ''
|
|
|
|
rm $out/share/tor-browser/distribution/policies.json
|
|
|
|
install -Dvm644 ${policiesJson} $out/share/tor-browser/distribution/policies.json
|
|
|
|
'';
|
|
|
|
});
|
2024-08-22 22:27:39 +03:00
|
|
|
|
|
|
|
hostRunTorBrowser = pkgs.writeScriptBin "tor-browser" ''
|
|
|
|
${pkgs.xorg.xhost}/bin/xhost +local:
|
|
|
|
ssh -X browser@${config.containers.browser.localAddress} tor-browser
|
|
|
|
${pkgs.xorg.xhost}/bin/xhost -local:
|
|
|
|
'';
|
2024-04-16 02:51:46 +03:00
|
|
|
in
|
|
|
|
{
|
|
|
|
options.local.programs.browsers.tor-browser = with lib; {
|
|
|
|
enable = mkEnableOption "tor-browser";
|
|
|
|
};
|
|
|
|
|
2024-08-22 22:27:39 +03:00
|
|
|
config = lib.mkIf cfg.enable {
|
|
|
|
environment.systemPackages = [ hostRunTorBrowser ];
|
2024-04-16 02:51:46 +03:00
|
|
|
|
2024-08-22 22:27:39 +03:00
|
|
|
hardware.pulseaudio = {
|
|
|
|
systemWide = true;
|
|
|
|
support32Bit = true;
|
|
|
|
tcp = {
|
|
|
|
enable = true;
|
|
|
|
anonymousClients.allowedIpRanges = [ "127.0.0.1" "192.168.7.0/24" ];
|
|
|
|
};
|
|
|
|
};
|
2024-04-16 02:51:46 +03:00
|
|
|
|
2024-08-22 22:27:39 +03:00
|
|
|
/*
|
2024-04-16 02:51:46 +03:00
|
|
|
networking = {
|
|
|
|
firewall.allowedTCPPorts = [ 4713 6000 ];
|
|
|
|
nat = {
|
|
|
|
enable = true;
|
|
|
|
internalInterfaces = [ "ve-browser" ];
|
|
|
|
externalInterface = cfg.container.externalInterface;
|
|
|
|
};
|
|
|
|
};
|
2024-08-22 22:27:39 +03:00
|
|
|
*/
|
2024-04-16 02:51:46 +03:00
|
|
|
|
2024-08-22 22:27:39 +03:00
|
|
|
containers.browser = {
|
|
|
|
autoStart = true;
|
|
|
|
privateNetwork = true;
|
|
|
|
hostAddress = "192.168.7.10";
|
|
|
|
localAddress = "192.168.7.11";
|
2024-04-16 02:51:46 +03:00
|
|
|
|
2024-08-22 22:27:39 +03:00
|
|
|
bindMounts = {
|
|
|
|
"/tmp/.X11-unix" = { };
|
|
|
|
};
|
2024-04-16 02:51:46 +03:00
|
|
|
|
2024-08-22 22:27:39 +03:00
|
|
|
config = { ... }: {
|
|
|
|
system.stateVersion = "23.11";
|
|
|
|
|
|
|
|
services.openssh = {
|
|
|
|
enable = true;
|
|
|
|
settings.X11Forwarding = true;
|
|
|
|
settings.PasswordAuthentication = true;
|
|
|
|
};
|
|
|
|
|
|
|
|
users.extraUsers.browser = {
|
|
|
|
isNormalUser = true;
|
|
|
|
home = "/home/browser";
|
|
|
|
password = "hello";
|
|
|
|
openssh.authorizedPrincipals = [ "jan@${config.containers.browser.hostAddress}" ];
|
|
|
|
# openssh.authorizedKeys.keys = cfg.container.sshAuthorizedKeys;
|
|
|
|
extraGroups = [ "pulse-access" ];
|
|
|
|
packages = [ torBrowser ];
|
2024-04-16 02:51:46 +03:00
|
|
|
};
|
2024-08-22 22:27:39 +03:00
|
|
|
|
|
|
|
environment.sessionVariables = {
|
|
|
|
DISPLAY = "${config.containers.browser.hostAddress}:0.0";
|
|
|
|
PULSE_SERVER = "tcp:${config.containers.browser.hostAddress}:4713";
|
|
|
|
XAUTHORITY = "/home/browser/.Xauthority";
|
|
|
|
DBUS_SESSION_BUS_ADDRESS = "";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2024-04-16 02:51:46 +03:00
|
|
|
}
|