From df277a62f7ebb56433f2f76f4980432b7ff3af94 Mon Sep 17 00:00:00 2001 From: Yan Lin Date: Thu, 31 Jul 2025 23:41:05 +0200 Subject: [PATCH] Initial commit of firefox modules with basic configs --- README.md | 35 ++++++++- flake.lock | 23 ++++++ flake.nix | 10 ++- modules/firefox.nix | 170 ++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 235 insertions(+), 3 deletions(-) create mode 100644 modules/firefox.nix diff --git a/README.md b/README.md index 0d67634..f867b05 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,8 @@ home-manager switch --flake github:Logan-Lin/nix-config#yanlin │ ├── zsh.nix # Zsh with Powerlevel10k and modern CLI tools │ ├── papis.nix # Reference management system │ ├── rsync.nix # File synchronization and backup -│ └── termscp.nix # Terminal file transfer client +│ ├── termscp.nix # Terminal file transfer client +│ └── firefox.nix # Firefox browser with extensions and bookmarks ├── system/ # System-level nix-darwin configurations │ ├── default.nix # System module imports │ └── macos-defaults.nix # macOS system preferences and customizations @@ -403,6 +404,38 @@ The configuration includes carefully selected programming fonts with icon patche The fonts are automatically installed and configured system-wide through the nix configuration, ensuring consistency across all development tools. +## 🌐 Web Browser: Firefox + +**Configuration**: `modules/firefox.nix` +**Purpose**: Declarative Firefox configuration with extensions, bookmarks, and privacy settings + +### Key Features: +- **Extensions Management**: Declarative installation of browser extensions via Nix +- **Bookmarks**: Pre-configured bookmarks with keywords for quick access +- **Privacy Settings**: Enhanced tracking protection and telemetry disabled +- **Search Engines**: Custom search engines with convenient aliases +- **Performance**: Hardware acceleration and WebRender enabled + +### Configured Extensions: +- **uBlock Origin**: Advanced ad and tracker blocking + +### Search Engine Aliases: +- `@np [query]` - Search Nix packages +- `@nw [query]` - Search NixOS Wiki + +### Privacy & Security: +- HTTPS-only mode enabled by default +- Enhanced tracking protection active +- All telemetry and experiments disabled +- Pocket integration removed + +### Usage: +```bash +# Firefox is managed declaratively through Nix +# Extensions are automatically installed and updated +# Bookmarks and settings sync across rebuilds +``` + ## 🌟 Specialized Tools ### 📚 Reference Management: papis diff --git a/flake.lock b/flake.lock index 3e124d7..a21adee 100644 --- a/flake.lock +++ b/flake.lock @@ -19,6 +19,28 @@ "type": "github" } }, + "firefox-addons": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "dir": "pkgs/firefox-addons", + "lastModified": 1753761817, + "narHash": "sha256-FE908x/ihUlr5yn1f+PTMyOjcwotGUodzn7Ej6zZf5U=", + "owner": "rycee", + "repo": "nur-expressions", + "rev": "b657cfddb78408e9b53b4a8aaeaac71fc7ea182e", + "type": "gitlab" + }, + "original": { + "dir": "pkgs/firefox-addons", + "owner": "rycee", + "repo": "nur-expressions", + "type": "gitlab" + } + }, "flake-parts": { "inputs": { "nixpkgs-lib": [ @@ -226,6 +248,7 @@ "root": { "inputs": { "claude-code": "claude-code", + "firefox-addons": "firefox-addons", "home-manager": "home-manager", "nix-darwin": "nix-darwin", "nixpkgs": "nixpkgs_2", diff --git a/flake.nix b/flake.nix index 32a3831..cc3763a 100644 --- a/flake.nix +++ b/flake.nix @@ -10,9 +10,13 @@ nixvim.url = "github:nix-community/nixvim"; nixvim.inputs.nixpkgs.follows = "nixpkgs"; claude-code.url = "github:sadjow/claude-code-nix"; + firefox-addons = { + url = "gitlab:rycee/nur-expressions?dir=pkgs/firefox-addons"; + inputs.nixpkgs.follows = "nixpkgs"; + }; }; - outputs = inputs@{ self, nix-darwin, nixpkgs, home-manager, nixvim, claude-code }: + outputs = inputs@{ self, nix-darwin, nixpkgs, home-manager, nixvim, claude-code, firefox-addons }: let configuration = { pkgs, ... }: { imports = [ @@ -53,6 +57,7 @@ ./modules/termscp.nix ./modules/rsync.nix ./modules/btop.nix + ./modules/firefox.nix ]; home.username = "yanlin"; @@ -80,6 +85,7 @@ gnumake zoxide ]; + fonts.fontconfig.enable = true; @@ -100,7 +106,7 @@ homeConfigurations.yanlin = home-manager.lib.homeManagerConfiguration { pkgs = nixpkgs.legacyPackages.aarch64-darwin; modules = [ homeConfiguration ]; - extraSpecialArgs = { inherit claude-code nixvim; }; + extraSpecialArgs = { inherit claude-code nixvim firefox-addons; }; }; }; } diff --git a/modules/firefox.nix b/modules/firefox.nix new file mode 100644 index 0000000..7dc5665 --- /dev/null +++ b/modules/firefox.nix @@ -0,0 +1,170 @@ +{ config, pkgs, lib, ... }@args: + +{ + programs.firefox = { + enable = true; + + profiles.yanlin = { + id = 0; + isDefault = true; + name = "yanlin"; + + # Extensions + extensions = { + packages = let + firefox-addons = args.firefox-addons or null; + in + if firefox-addons != null then + with firefox-addons.packages.${pkgs.system}; [ + ublock-origin + ] + else []; + }; + + # Bookmarks + bookmarks = { + force = true; + settings = [ + { + name = "Toolbar"; + toolbar = true; + bookmarks = [ + { + name = "My Home"; + url = "https://home.nas.yanlincs.com/lovelace/0"; + } + { + name = "Media"; + bookmarks = [ + { + name = "Immich"; + url = "https://photo.nas.yanlincs.com/photos"; + } + { + name = "Plex"; + url = "https://plex.nas.yanlincs.com"; + } + { + name = "Emby"; + url = "https://emby.nas.yanlincs.com"; + } + { + name = "Library"; + bookmarks = [ + { + name = "Sonnar"; + url = "https://sonnar.nas.yanlincs.com"; + } + { + name = "Radarr"; + url = "https://radarr.nas.yanlincs.com"; + } + { + name = "qBittorrent"; + url = "https://qbit.nas.yanlincs.com"; + } + { + name = "MeTube"; + url = "https://metube.nas.yanlincs.com"; + } + ]; + } + ]; + } + ]; + } + ]; + }; + + # Search configuration + search = { + force = true; + default = "ddg"; + + engines = { + "Nix Packages" = { + urls = [{ + template = "https://search.nixos.org/packages"; + params = [ + { name = "channel"; value = "unstable"; } + { name = "query"; value = "{searchTerms}"; } + ]; + }]; + icon = "''${pkgs.nixos-icons}/share/icons/hicolor/scalable/apps/nix-snowflake.svg"; + definedAliases = [ "@np" ]; + }; + + "NixOS Wiki" = { + urls = [{ template = "https://wiki.nixos.org/index.php?search={searchTerms}"; }]; + icon = "https://wiki.nixos.org/favicon.png"; + definedAliases = [ "@nw" ]; + }; + }; + }; + + # Firefox settings + settings = { + # General preferences + "browser.startup.homepage" = "about:home"; + "browser.newtabpage.enabled" = true; + + # New tab page - show only search bar + "browser.newtabpage.activity-stream.feeds.topsites" = false; + "browser.newtabpage.activity-stream.feeds.section.highlights" = false; + "browser.newtabpage.activity-stream.feeds.section.topstories" = false; + "browser.newtabpage.activity-stream.feeds.system.topsites" = false; + "browser.newtabpage.activity-stream.feeds.system.topstories" = false; + "browser.newtabpage.activity-stream.showSponsored" = false; + "browser.newtabpage.activity-stream.showSponsoredTopSites" = false; + + # Privacy settings + "privacy.trackingprotection.enabled" = true; + "privacy.trackingprotection.socialtracking.enabled" = true; + "privacy.donottrackheader.enabled" = true; + + # Performance + "gfx.webrender.all" = true; + "media.ffmpeg.vaapi.enabled" = true; + "media.hardware-video-decoding.force-enabled" = true; + + # UI preferences + "browser.tabs.loadInBackground" = true; + "browser.ctrlTab.recentlyUsedOrder" = true; + + # Bookmarks toolbar (only show on new tab/home page) + "browser.toolbars.bookmarks.visibility" = "newtab"; + + # Downloads + "browser.download.useDownloadDir" = false; + "browser.download.always_ask_before_handling_new_types" = true; + + # Security + "dom.security.https_only_mode" = true; + "dom.security.https_only_mode_ever_enabled" = true; + + # Disable telemetry + "datareporting.healthreport.uploadEnabled" = false; + "datareporting.policy.dataSubmissionEnabled" = false; + "toolkit.telemetry.unified" = false; + "toolkit.telemetry.enabled" = false; + "toolkit.telemetry.server" = "data:,"; + "toolkit.telemetry.archive.enabled" = false; + "toolkit.telemetry.newProfilePing.enabled" = false; + "toolkit.telemetry.shutdownPingSender.enabled" = false; + "toolkit.telemetry.updatePing.enabled" = false; + "toolkit.telemetry.bhrPing.enabled" = false; + "toolkit.telemetry.firstShutdownPing.enabled" = false; + + # Disable experiments + "experiments.activeExperiment" = false; + "experiments.enabled" = false; + "experiments.supported" = false; + "network.allow-experiments" = false; + + # Disable Pocket + "extensions.pocket.enabled" = false; + "browser.newtabpage.activity-stream.section.highlights.includePocket" = false; + }; + }; + }; +}