system/modules/nixos/programs/browsers/default.nix

99 lines
2.6 KiB
Nix
Raw Normal View History

{ config, pkgs, lib, ... }:
let
cfg = config.local.programs.browsers;
contPackages =
lib.optional cfg.tor-browser.enable cfg.tor-browser.finalPackage
++ lib.optional cfg.librewolf.enable cfg.librewolf.finalPackage
++ lib.optional cfg.mullvad-browser.enable cfg.mullvad-browser.finalPackage
++ lib.optional cfg.ungoogled-chromium.enable cfg.ungoogled-chromium.package;
hostPackages = lib.flip map contPackages (p:
2024-08-28 18:06:29 +03:00
let
hostRunBrowser = pkgs.writeScript "cont-run-browser" ''
2024-09-30 20:13:34 +03:00
sudo nixos-container run browsers -- su -l jan -c "$*"
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
''
);
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
./ungoogled-chromium.nix
2024-04-16 02:51:46 +03:00
];
config = lib.mkIf isEnable {
environment.systemPackages = hostPackages;
local.sound.systemWide = true;
containers.browsers = {
autoStart = true;
ephemeral = true;
bindMounts = lib.mkMerge [
{
"/tmp/.X11-unix" = { };
2024-09-30 20:13:34 +03:00
"/home/jan/Downloads" = {
isReadOnly = false;
hostPath = "/home/jan/downloads/browser";
};
}
(lib.mkIf config.hardware.graphics.enable {
"/run/opengl-driver/lib" = { };
})
(lib.mkIf config.hardware.graphics.enable32Bit {
"/run/opengl-driver-32/lib" = { };
})
(lib.mkIf cfg.librewolf.enable {
2024-09-30 20:13:34 +03:00
"/home/jan/.librewolf" = {
isReadOnly = false;
2024-09-30 20:13:34 +03:00
hostPath = "/persistent/per-machine/browsers/home/jan/.librewolf";
};
})
2024-09-30 20:13:34 +03:00
(lib.mkIf config.local.programs.communication.telegram.enable {
"/home/jan/downloads/telegram" = { };
})
];
config = { pkgs, ... }: {
system.stateVersion = "23.11";
fonts = {
inherit (config.fonts) enableDefaultPackages packages;
fontconfig = { inherit (config.fonts.fontconfig) defaultFonts; };
};
2024-09-30 20:13:34 +03:00
users.users.jan = {
isNormalUser = true;
2024-09-30 20:13:34 +03:00
home = "/home/jan";
password = "hello";
extraGroups = [ "pulse-access" ];
packages = contPackages;
};
environment.sessionVariables = {
DISPLAY = ":0";
PULSE_SERVER = "tcp:127.0.0.1:4713";
};
};
};
};
2024-04-16 02:51:46 +03:00
}