home-manager Firefox configuration with extensions, use the latest features of the…
- User
home-manager Firefox configuration with extensions, use the latest features of the unstable version
- Assistant
Below is a complete example of a Home Manager configuration for Firefox that uses the unstable version of the package. This setup includes popular extensions and leverages the latest features from the unstable channel of Nixpkgs. By using the unstable Firefox package, you'll get access to the most recent updates, bug fixes, and experimental features.
Key Points:
- Unstable Version: We're importing the unstable Nixpkgs channel to use its Firefox package. This assumes you have the unstable channel set up (e.g., via
nix-channel --add https://nixos.org/channels/nixpkgs-unstable). If not, you'll need to configure that first. - Extensions: I've included a few popular extensions (e.g., uBlock Origin for ad-blocking, Dark Reader for night mode). You can add or remove them as needed. Extensions are managed via Home Manager's Firefox module, which installs them as part of your profile.
- Latest Features: Using the unstable package ensures you get the newest Firefox features. Home Manager will handle the configuration, including setting preferences.
- How to Use: Add this to your
home.nixfile (or equivalent). Then, runhome-manager switchto apply the changes. - Caveats:
- Firefox extensions in Nixpkgs are pre-built and may not always be the absolute latest version. However, they are from the unstable channel here, so they'll be as up-to-date as possible.
- Make sure your Nix environment has access to the unstable channel. If you're using a flake-based setup, you can adapt this accordingly.
Configuration Code
Here's the Nix configuration:
{ config, pkgs, ... }: let # Import the unstable Nixpkgs channel unstable = import <unstable> {}; # Assumes you have 'nixpkgs-unstable' channel added in { # Enable Home Manager's Firefox module programs.firefox = { enable = true; # Use the unstable version of Firefox package = unstable.firefox; profiles = { # Define a default profile default = { id = 0; # Internal ID for the profile name = "default"; # Name of the profile isDefault = true; # Set this as the default profile # Add extensions from the unstable channel extensions = with unstable.firefoxExtensions; [ ublock-origin # Ad blocker darkreader # Dark mode for websites privacy-badger # Privacy protection # Add more extensions as needed, e.g., vimium for keyboard navigation # vimium ]; # Configure Firefox settings (preferences) settings = { # General settings "browser.startup.homepage" = "https://www.example.com"; # Set homepage "browser.newtabpage.enabled" = false; # Disable new tab page "browser.newtabpage.activity-stream.feeds.system.topstories" = false; # Disable sponsored stories # Privacy and security settings "dom.security.https_only_mode" = true; # Enforce HTTPS-only mode "privacy.trackingprotection.enabled" = true; # Enable tracking protection "signon.rememberSignons" = false; # Disable password saving # Performance and experimental features "browser.tabs.remote.autostart" = true; # Enable multi-process tabs (E10S) "network.http.max-connections" = 1000; # Increase max connections for better performance "media.ffmpeg.vaapi.enabled" = true; # Enable VAAPI for hardware acceleration (if supported) # UI customizations "browser.ui.toolbarpins" = 0; # Customize toolbar "layout.css.devPixelsPerPx" = "1.0"; # Set DPI scaling }; # Optional: Search engines (add custom ones if needed) search = { default = "Google"; # Set default search engine force = true; # Force the search engines to be set engines = { "NixOS Search" = { urls = [{ template = "https://search.nixos.org/packages"; params = [ { name = "type"; value = "packages"; } { name = "query"; value = "{searchTerms}"; } ]; }]; icon = "${pkgs.nixos-icons}/share/icons/hicolor/scalable/apps/nix-snowflake.svg"; definedAliases = [ "@nix" ]; }; # You can add more engines here }; }; # Extra preferences (e.g., user scripts or other customizations) extraConfig = '' // Example: User script or additional JS config user_pref("example.preference", true); ''; }; }; }; }Explanation:
-
Importing Unstable Nixpkgs:
- The line
unstable = import <unstable> {};imports the unstable channel. This requires you to have added the channel vianix-channel add https://nixos.org/channels/nixpkgs-unstable unstableand runnix-channel update. - If you're using flakes, you could replace this with a flake input, e.g.,
unstable = import (fetchTarball "https://github.com/NixOS/nixpkgs/archive/nixpkgs-unstable.tar.gz") {};.
- The line
-
Firefox Package:
package = unstable.firefox;ensures you're using the latest unstable build of Firefox, which includes new features like improved privacy controls, better performance, and experimental APIs.
-
Profiles:
- We're defining a single profile named "default". You can add more profiles if needed (e.g., for work vs. personal use).
extensions: This lists extensions fromunstable.firefoxExtensions. Home Manager will install and enable them automatically.
-
Settings:
- The
settingsattribute allows you to configure Firefox preferences directly. These are based on Firefox'sabout:configsettings. - I've included a mix of general, privacy, performance, and UI settings to demonstrate. You can customize these further based on your needs.
- The
-
Search Engines:
- Added an example for a custom NixOS search engine. This shows how to integrate search providers.
-
Applying the Configuration:
- Save this in your Home Manager configuration file (e.g.,
~/.config/home-manager/home.nix). - Run
home-manager switchto build and activate the configuration. - If you encounter issues (e.g., channel not found), verify your channels with
nix-channel --list.
- Save this in your Home Manager configuration file (e.g.,
Tips for Customization:
- More Extensions: Check available extensions in
unstable.firefoxExtensionsby runningnix repl '<unstable>'and typingfirefoxExtensions. Add them to the list, e.g.,sponsorblockfor skipping sponsored segments on YouTube. - Updating: To keep things fresh, regularly update your channels with
nix-channel updateand re-runhome-manager switch. - Troubleshooting:
- If extensions don't work, ensure they are compatible with your Firefox version.
- For more advanced setups, consider using Home Manager's
extraConfigfor custom userChrome.js or userContent.js files. - If you're on a non-NixOS system, Home Manager still works, but you might need to install it via Nix.
This configuration should give you a solid starting point for a feature-rich Firefox setup with the latest unstable features. If you need further adjustments, let me know!
- Unstable Version: We're importing the unstable Nixpkgs channel to use its Firefox package. This assumes you have the unstable channel set up (e.g., via
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.