2024-08-22 22:27:39 +03:00
|
|
|
{ config, pkgs, lib, ... }:
|
|
|
|
|
|
|
|
let
|
|
|
|
cfg = config.local.programs.browsers;
|
|
|
|
|
|
|
|
hostAddress = "192.168.7.10";
|
|
|
|
localAddress = "192.168.7.11";
|
|
|
|
|
|
|
|
contPackages =
|
|
|
|
lib.optional cfg.tor-browser.enable cfg.tor-browser.package
|
|
|
|
++ lib.optional cfg.librewolf.enable cfg.librewolf.package
|
|
|
|
++ lib.optional cfg.mullvad-browser.enable cfg.mullvad-browser.package;
|
|
|
|
|
|
|
|
hostPackages = lib.flip map contPackages (p:
|
2024-08-28 18:06:29 +03:00
|
|
|
let
|
|
|
|
hostRunBrowser = pkgs.writeScript "cont-run-browser" ''
|
|
|
|
host=browsers.containers
|
|
|
|
if [ -z "$(ssh-keygen -F $host)" ]; then
|
|
|
|
ssh-keyscan -H $host >> ~/.ssh/known_hosts
|
|
|
|
fi
|
2024-09-04 10:34:51 +03:00
|
|
|
ssh -o PubkeyAuthentication=no kira@$host $@
|
2024-08-28 18:06:29 +03:00
|
|
|
'';
|
|
|
|
|
|
|
|
hostBrowserScript = pkgs.writeScriptBin "${p.meta.mainProgram}" ''
|
|
|
|
${hostRunBrowser} ${p.meta.mainProgram} $@
|
|
|
|
'';
|
|
|
|
in
|
|
|
|
pkgs.runCommand "${p.meta.mainProgram}" { } ''
|
|
|
|
mkdir $out
|
|
|
|
cp -r ${hostBrowserScript}/bin $out/bin
|
|
|
|
cp -r ${p}/share $out/share
|
2024-08-22 22:27:39 +03:00
|
|
|
''
|
|
|
|
);
|
|
|
|
|
|
|
|
isEnable = cfg.tor-browser.enable
|
|
|
|
or cfg.librewolf.enable
|
|
|
|
or cfg.mullvad-browser.enable;
|
|
|
|
in
|
2024-04-16 02:51:46 +03:00
|
|
|
{
|
|
|
|
imports = [
|
|
|
|
./tor-browser.nix
|
|
|
|
./mullvad-browser.nix
|
|
|
|
./librewolf.nix
|
|
|
|
];
|
2024-08-22 22:27:39 +03:00
|
|
|
|
|
|
|
config = lib.mkIf isEnable {
|
2024-08-28 13:51:55 +03:00
|
|
|
environment.systemPackages = hostPackages;
|
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" ];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
networking = {
|
|
|
|
firewall = {
|
|
|
|
allowedTCPPorts = [ 4713 ];
|
2024-08-28 18:06:29 +03:00
|
|
|
allowedTCPPortRanges = [
|
2024-09-02 12:34:41 +03:00
|
|
|
{ from = 3000; to = 3999; }
|
|
|
|
{ from = 5000; to = 5999; }
|
|
|
|
{ from = 8000; to = 9999; }
|
2024-08-28 18:06:29 +03:00
|
|
|
{ from = 32000; to = 33999; }
|
|
|
|
];
|
2024-08-22 22:27:39 +03:00
|
|
|
trustedInterfaces = [ "ve-*" ];
|
|
|
|
};
|
|
|
|
nat = {
|
|
|
|
enable = true;
|
|
|
|
internalInterfaces = [ "ve-browsers" ];
|
|
|
|
externalInterface = "wg0";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
containers.browsers = {
|
|
|
|
autoStart = true;
|
|
|
|
ephemeral = true;
|
|
|
|
|
|
|
|
privateNetwork = true;
|
|
|
|
inherit hostAddress localAddress;
|
|
|
|
|
|
|
|
bindMounts = lib.mkMerge [
|
|
|
|
{
|
2024-09-04 10:34:51 +03:00
|
|
|
"/tmp/.X11-unix" = {};
|
2024-08-22 22:27:39 +03:00
|
|
|
"/etc/ssh/keys" = {
|
|
|
|
isReadOnly = false;
|
2024-09-06 10:41:31 +03:00
|
|
|
hostPath = "/persistent/per-machine/browsers/etc/ssh/keys";
|
2024-08-22 22:27:39 +03:00
|
|
|
};
|
|
|
|
"/home/kira/Downloads" = {
|
|
|
|
isReadOnly = false;
|
|
|
|
hostPath = "/home/jan/downloads/browser";
|
|
|
|
};
|
2024-09-08 02:36:45 +03:00
|
|
|
}
|
|
|
|
(lib.mkIf config.hardware.graphics.enable {
|
2024-09-04 00:11:57 +03:00
|
|
|
"/run/opengl-driver/lib" = { };
|
2024-09-08 02:36:45 +03:00
|
|
|
})
|
|
|
|
(lib.mkIf config.hardware.graphics.enable32Bit {
|
2024-09-04 00:11:57 +03:00
|
|
|
"/run/opengl-driver-32/lib" = { };
|
2024-09-08 02:36:45 +03:00
|
|
|
})
|
2024-08-22 22:27:39 +03:00
|
|
|
(lib.mkIf cfg.librewolf.enable {
|
|
|
|
"/home/kira/.librewolf" = {
|
|
|
|
isReadOnly = false;
|
2024-09-06 10:41:31 +03:00
|
|
|
hostPath = "/persistent/per-machine/browsers/home/kira/.librewolf";
|
2024-08-22 22:27:39 +03:00
|
|
|
};
|
|
|
|
})
|
|
|
|
];
|
|
|
|
|
|
|
|
config = { pkgs, ... }: {
|
|
|
|
system.stateVersion = "23.11";
|
|
|
|
|
2024-08-28 01:33:45 +03:00
|
|
|
# Inherit configs from host
|
2024-08-28 18:06:29 +03:00
|
|
|
networking.hosts = lib.mkMerge [
|
|
|
|
config.networking.hosts
|
|
|
|
{ "${hostAddress}" = [ "host" ]; }
|
|
|
|
];
|
2024-08-28 01:33:45 +03:00
|
|
|
fonts = {
|
|
|
|
inherit (config.fonts) enableDefaultPackages packages;
|
|
|
|
fontconfig = { inherit (config.fonts.fontconfig) defaultFonts; };
|
|
|
|
};
|
2024-08-28 00:00:55 +03:00
|
|
|
|
2024-08-22 22:27:39 +03:00
|
|
|
services.openssh = {
|
|
|
|
enable = true;
|
2024-08-28 19:57:02 +03:00
|
|
|
settings = {
|
|
|
|
PasswordAuthentication = true;
|
2024-09-05 18:47:51 +03:00
|
|
|
MaxAuthTries = 2;
|
2024-08-28 19:57:02 +03:00
|
|
|
};
|
2024-08-22 22:27:39 +03:00
|
|
|
hostKeys = [
|
|
|
|
{
|
|
|
|
bits = 4096;
|
|
|
|
path = "/etc/ssh/keys/ssh_host_rsa_key";
|
|
|
|
type = "rsa";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
path = "/etc/ssh/keys/ssh_host_ed25519_key";
|
|
|
|
type = "ed25519";
|
|
|
|
}
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
|
|
|
users.users.kira = {
|
|
|
|
isNormalUser = true;
|
|
|
|
home = "/home/kira";
|
|
|
|
password = "hello";
|
|
|
|
extraGroups = [ "pulse-access" ];
|
|
|
|
packages = contPackages;
|
|
|
|
};
|
|
|
|
|
|
|
|
environment.sessionVariables = {
|
2024-09-04 10:34:51 +03:00
|
|
|
DISPLAY = ":0";
|
2024-08-22 22:27:39 +03:00
|
|
|
PULSE_SERVER = "tcp:${hostAddress}:4713";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2024-04-16 02:51:46 +03:00
|
|
|
}
|