nixos-system-config/overlays/nixpkgs/firefox.nix

46 lines
1.3 KiB
Nix
Raw Normal View History

2025-01-24 20:17:36 +01:00
# Shamelessly stolen most parts from here:
# https://github.com/ryan4yin/nix-config/blob/7deed26cc5a3af2072b8c89a688f265607babc80/hardening/nixpaks/firefox.nix
2025-01-24 16:50:18 +01:00
2025-01-24 18:35:52 +01:00
{ ... }: final: prev: {
2025-01-24 17:17:19 +01:00
firefox-esr = let
2025-01-24 18:35:52 +01:00
sandboxed-firefox-esr = prev.mkNixPak {
config = { sloth, ... }: {
app.package = prev.firefox-esr;
2025-01-24 18:17:52 +01:00
app.binPath = "bin/firefox-esr";
flatpak.appId = "org.mozilla.firefox";
2025-01-24 20:17:36 +01:00
2025-01-24 18:17:52 +01:00
dbus.policies = {
"org.mozilla.firefox.*" = "own";
2025-01-24 20:17:36 +01:00
"org.mozilla.firefox_esr.*" = "own";
2025-01-24 18:17:52 +01:00
"org.mozilla.firefox_beta.*" = "own";
2025-01-24 20:17:36 +01:00
"org.mpris.MediaPlayer2.firefox.*" = "own";
2025-01-24 18:17:52 +01:00
"org.freedesktop.NetworkManager" = "talk";
};
2025-01-24 20:17:36 +01:00
bubblewrap = {
bind.dev = [ "/dev/shm" ];
tmpfs = [ "/tmp" ];
2025-01-24 18:17:52 +01:00
bind.rw = [
2025-01-24 20:17:36 +01:00
[ (sloth.mkdir (sloth.concat' sloth.xdgConfigHome "/mozilla")) (sloth.concat' sloth.homeDir "/.mozilla")]
sloth.xdgDownloadDir
2025-01-24 18:17:52 +01:00
];
bind.ro = [
"/sys/bus/pci"
2025-01-24 20:17:36 +01:00
["${prev.firefox-esr}/lib/firefox" "/app/etc/firefox"]
(sloth.concat' sloth.xdgConfigHome "/dconf")
2025-01-24 18:17:52 +01:00
];
2025-01-24 20:17:36 +01:00
sockets = {
x11 = false;
wayland = true;
pipewire = true;
};
2025-01-24 18:17:52 +01:00
};
2025-01-24 16:50:18 +01:00
};
};
2025-01-24 17:17:19 +01:00
in
2025-01-24 18:48:25 +01:00
sandboxed-firefox-esr.config.env;
2025-01-24 16:50:18 +01:00
}