From b7250f77b5b8a352b97a133e0ff36b078560fe91 Mon Sep 17 00:00:00 2001 From: Lucien Cartier-Tilet Date: Sat, 28 Mar 2026 17:03:50 +0100 Subject: [PATCH] feat(firefox): dedicated module and tridactyl config --- users/modules/desktop/default.nix | 2 + users/modules/desktop/firefox.nix | 70 +++++++++++++++++++++++++++++++ users/phundrak/home.nix | 70 +++++++++++++++++++++++++++++++ users/phundrak/packages.nix | 2 - 4 files changed, 142 insertions(+), 2 deletions(-) create mode 100644 users/modules/desktop/firefox.nix diff --git a/users/modules/desktop/default.nix b/users/modules/desktop/default.nix index 206794f..9337110 100644 --- a/users/modules/desktop/default.nix +++ b/users/modules/desktop/default.nix @@ -9,6 +9,7 @@ in { imports = [ ./caelestia.nix ./eww.nix + ./firefox.nix ./hyprland.nix ./kdeconnect.nix ./kitty.nix @@ -25,6 +26,7 @@ in { options.home.desktop.fullDesktop = mkEnableOption "Enable options for graphical environments"; config.home.desktop = { eww.enable = mkDefault cfg.fullDesktop; + firefox.enable = mkDefault cfg.fullDesktop; hyprland.enable = mkDefault cfg.fullDesktop; kdeconnect.enable = mkDefault cfg.fullDesktop; kitty.enable = mkDefault cfg.fullDesktop; diff --git a/users/modules/desktop/firefox.nix b/users/modules/desktop/firefox.nix new file mode 100644 index 0000000..36ca4b5 --- /dev/null +++ b/users/modules/desktop/firefox.nix @@ -0,0 +1,70 @@ +{ + config, + lib, + inputs, + pkgs, + ... +}: +with lib; let + cfg = config.home.desktop.firefox; + inherit (pkgs.stdenv.hostPlatform) system; + zen = inputs.zen-browser.packages.${system}.default; + settingsToLines = settings: + concatStringsSep "\n" (mapAttrsToList (name: value: "set ${name} ${toString value}") settings); +in { + options.home.desktop.firefox = { + enable = mkEnableOption "enable Firefox"; + useZen = mkEnableOption "use Zen instead of Firefox"; + tridactyl = { + enable = mkEnableOption "enable Tridactyl"; + preConfig = mkOption { + description = "Lines to add to the beginning of tridactylrc"; + type = types.lines; + default = ""; + }; + config = mkOption { + type = with types; + attrsOf (oneOf [ + int + str + bool + ]); + description = "Tridactyl settings (converted to 'set key value' lines)"; + default = {}; + example = { + smoothscroll = true; + history = 1000; + }; + }; + extraConfig = mkOption { + description = "Extra lines to add to tridactylrc (for bindings, autocmds, etc)"; + type = types.lines; + default = ""; + }; + }; + }; + + config = mkIf cfg.enable { + programs.firefox = { + inherit (cfg) enable; + package = + if cfg.useZen + then zen + else pkgs.firefox; + nativeMessagingHosts = lists.optional cfg.tridactyl.enable pkgs.tridactyl-native; + }; + xdg.configFile."tridactyl/tridactylrc" = mkIf cfg.tridactyl.enable { + text = concatStringsSep "\n" (filter (s: s != "") [ + cfg.tridactyl.preConfig + (settingsToLines (cfg.tridactyl.config + // { + browser = + if cfg.useZen + then "zen" + else "firefox"; + })) + cfg.tridactyl.extraConfig + ]); + }; + }; +} diff --git a/users/phundrak/home.nix b/users/phundrak/home.nix index 9536b3d..f122ae6 100644 --- a/users/phundrak/home.nix +++ b/users/phundrak/home.nix @@ -65,6 +65,76 @@ }; desktop = { caelestia.enable = true; + firefox = { + enable = true; + useZen = true; + tridactyl = { + enable = true; + preConfig = "sanitise tridactyllocal tridactylsync"; + config = { + editorcmd = "emacsclient -c"; + keyboardlayoutbase = "bepo"; + keyboardlayoutforce = "true"; + hintchars = "auiectsr"; + smothscroll = "true"; + }; + extraConfig = '' + unbind h + unbind j + unbind k + unbind l + unbind c + unbind t + unbind s + unbind r + unbind H + unbind J + unbind K + unbind L + unbind C + unbind T + unbind S + unbind R + + " === Bépo layout — scrolling (ctsr = hjkl) === + bind c scrollpx -300 0 + bind t scrollline 5 + bind s scrollline -5 + bind r scrollpx 300 0 + + " Half/full page scroll (replacing C-f/C-b/C-d/C-u) + bind scrollpage 0.5 + bind scrollpage -0.5 + + " === History navigation (C/R = H/L) === + bind C back + bind R forward + + " === Tab navigation (T/S = J/K) === + bind T tabprev + bind S tabnext + + " === Displaced commands === + " reload was on r → move to h (bépo's 'replace' position) + bind h reload + bind H reloadhard + + " tabopen was on t → move to j (bépo's 'find char to' position) + bind j fillcmdline tabopen + + unbind ^http(s?)://youtube\.com f + unbind ^http(s?)://youtube\.com t + unbind ^http(s?)://youtube\.com l + unbind ^http(s?)://youtube\.com j + unbind ^http(s?)://twitch\.tv f + + bind < urlincrement -1 + bind > urlincrement 1 + bind ypv js tri.native.run(`mpv --ytdl-format="[height >=? 480]" --ontop --fs "''${document.location.href}"`) + bind ypm hint -JF e => tri.native.run(`mpv --ytdl-format="[height >=? 480]" --ontop --fs "''${e.href}"`) + ''; + }; + }; spotify = { enable = true; spicetify.enable = true; diff --git a/users/phundrak/packages.nix b/users/phundrak/packages.nix index e858141..ba17518 100644 --- a/users/phundrak/packages.nix +++ b/users/phundrak/packages.nix @@ -9,7 +9,6 @@ with lib; let handy = pkgs.callPackage ../../packages/handy.nix {}; inkdrop = pkgs.callPackage ../../packages/inkdrop.nix {}; pumo-system-info = inputs.pumo-system-info.packages.${system}.default; - zen = inputs.zen-browser.packages.${system}.default; in { programs.bun.enable = true; home.packages = with pkgs; [ @@ -52,7 +51,6 @@ in { scrcpy syncthing watchmate - zen # Games atlauncher