Zen Browser: Difference between revisions

This page discusses on how to install the zen browser
 
Miniluz (talk | contribs)
Added an example for configurating Zen
 
(2 intermediate revisions by one other user not shown)
Line 1: Line 1:
{{Infobox application
| name = Zen
| type = Native
| image = Zen-logo-black.png
| website = https://zen-browser.app/
| bugTracker = https://github.com/zen-browser/desktop/issues
| github = https://github.com/zen-browser/desktop
| programmingLanguage = C++
}}
'''Zen''' is a firefox based browser that promises a calmer internet, and features a sideways based tab system.
'''Zen''' is a firefox based browser that promises a calmer internet, and features a sideways based tab system.


Line 30: Line 39:
}
}
</syntaxhighlight>After rebuilding, Zen will be installed system-wide.
</syntaxhighlight>After rebuilding, Zen will be installed system-wide.
{{Infobox application
 
| name = Zen
== Configuration ==
| type = Native
This is an example of a pure, declarative, wrapper-based configuration independent of NixOS and home-manager (though it is presented as a NixOS module for convenience). Extensions are not packaged through Nix, but are installed by the browser upon startup. It should also work on any Firefox based browser.<syntaxhighlight lang="nix">
| image = https://raw.githubusercontent.com/zen-browser/.github/refs/heads/main/profile/logo-black.png
{
| website = https://zen-browser.app/
  inputs,
| bugTracker = https://github.com/zen-browser/desktop/issues
  pkgs,
| github = https://github.com/zen-browser/desktop
  lib,
| programmingLanguage = C++
  ...
}}
}:
let
  extension = shortId: guid: {
    name = guid;
    value = {
      install_url = "https://addons.mozilla.org/en-US/firefox/downloads/latest/${shortId}/latest.xpi";
      installation_mode = "normal_installed";
    };
  };
 
  prefs = {
    # Check these out at about:config
    "extensions.autoDisableScopes" = 0;
    "extensions.pocket.enabled" = false;
    # ...
  };
 
  extensions = [
    # To add additional extensions, find it on addons.mozilla.org, find
    # the short ID in the url (like https://addons.mozilla.org/en-US/firefox/addon/!SHORT_ID!/)
    # Then go to https://addons.mozilla.org/api/v5/addons/addon/!SHORT_ID!/ to get the guid
    (extension "ublock-origin" "uBlock0@raymondhill.net")
    # ...
  ];
 
in
{
  environment.systemPackages = [
    (pkgs.wrapFirefox
      inputs.zen-browser.packages.${pkgs.stdenv.hostPlatform.system}.zen-browser-unwrapped
      {
        extraPrefs = lib.concatLines (
          lib.mapAttrsToList (
            name: value: ''lockPref(${lib.strings.toJSON name}, ${lib.strings.toJSON value});''
          ) prefs
        );
 
        extraPolicies = {
          DisableTelemetry = true;
          ExtensionSettings = builtins.listToAttrs extensions;
 
          SearchEngines = {
            Default = "ddg";
            Add = [
              {
                Name = "nixpkgs packages";
                URLTemplate = "https://search.nixos.org/packages?query={searchTerms}";
                IconURL = "https://wiki.nixos.org/favicon.ico";
                Alias = "@np";
              }
              {
                Name = "NixOS options";
                URLTemplate = "https://search.nixos.org/options?query={searchTerms}";
                IconURL = "https://wiki.nixos.org/favicon.ico";
                Alias = "@no";
              }
              {
                Name = "NixOS Wiki";
                URLTemplate = "https://wiki.nixos.org/w/index.php?search={searchTerms}";
                IconURL = "https://wiki.nixos.org/favicon.ico";
                Alias = "@nw";
              }
              {
                Name = "noogle";
                URLTemplate = "https://noogle.dev/q?term={searchTerms}";
                IconURL = "https://noogle.dev/favicon.ico";
                Alias = "@ng";
              }
            ];
          };
        };
      }
    )
  ];
}
</syntaxhighlight>