From f231a95fbdeaadf6306e4cce0ad2e59c6434f5db Mon Sep 17 00:00:00 2001 From: Guanran928 <68757440+Guanran928@users.noreply.github.com> Date: Mon, 13 Nov 2023 18:48:11 -0600 Subject: [PATCH 1/2] browsers/firefox: init --- pkgs/browsers/firefox/default.nix | 56 +++++++++++++++++++++++++++++++ pkgs/default.nix | 1 + 2 files changed, 57 insertions(+) create mode 100644 pkgs/browsers/firefox/default.nix diff --git a/pkgs/browsers/firefox/default.nix b/pkgs/browsers/firefox/default.nix new file mode 100644 index 0000000..f59f831 --- /dev/null +++ b/pkgs/browsers/firefox/default.nix @@ -0,0 +1,56 @@ +{ + builders, + nixpakModules, + pkgs, + ... +}: { + packages.firefox = builders.mkNixPakPackage { + config = { + config, + sloth, + ... + }: { + app.package = pkgs.firefox; + app.binPath = "bin/firefox"; + flatpak.appId = "org.mozilla.firefox"; + + imports = [ + nixpakModules.gui-base + nixpakModules.network + ]; + + # https://github.com/schizofox/schizofox/blob/main/modules/hm/default.nix + dbus.policies = { + "org.mozilla.firefox.*" = "own"; # firefox + # "org.mozilla.firefox_beta.*" = "own"; # firefox beta (?) + # "io.gitlab.librewolf.*" = "own"; # librewolf + }; + + bubblewrap = let + envSuffix = envKey: sloth.concat' (sloth.env envKey); + in { + bind.rw = [ + (sloth.concat' sloth.homeDir "/.mozilla") + (sloth.concat' sloth.homeDir "/Downloads") + + # Unsure + "/tmp/.X11-unix" + (sloth.envOr "XAUTHORITY" "/no-xauth") + (envSuffix "XDG_RUNTIME_DIR" "/dconf") + ]; + bind.ro = [ + # To actually make Firefox run + "/sys/bus/pci" + ["${config.app.package}/lib/firefox" "/app/etc/firefox"] + + # Use correct timezone + "/etc/localtime" + + # Unsure + (sloth.concat' sloth.xdgConfigHome "/dconf") + ]; + }; + }; + }; +} + diff --git a/pkgs/default.nix b/pkgs/default.nix index 632fda6..4aab256 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -5,6 +5,7 @@ }; imports = [ ./browsers/chromium + ./browsers/firefox ./gnome/calculator ./gnome/maps ]; From 28dc18485df09e5ffc9604099dcef13bbaf396ac Mon Sep 17 00:00:00 2001 From: Guanran928 <68757440+Guanran928@users.noreply.github.com> Date: Tue, 14 Nov 2023 14:53:48 +0800 Subject: [PATCH 2/2] gui-base.nix: exception when `WAYLAND_DISPLAY` does not exist ref: https://github.com/schizofox/schizofox/blob/f1372e306349f1b154dada0ceea51fc6b4b21036/modules/hm/default.nix#L131-L135 --- pkgs/modules/gui-base.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/modules/gui-base.nix b/pkgs/modules/gui-base.nix index f96eb29..090d1be 100644 --- a/pkgs/modules/gui-base.nix +++ b/pkgs/modules/gui-base.nix @@ -32,7 +32,7 @@ in (sloth.concat [ (sloth.env "XDG_RUNTIME_DIR") "/" - (sloth.env "WAYLAND_DISPLAY") + (sloth.envOr "WAYLAND_DISPLAY" "no") ]) (envSuffix "XDG_RUNTIME_DIR" "/at-spi/bus")