{ config, lib, pkgs, ... }: let cfg = config.profiles.browsing; fixSopsPrefix = x: y: builtins.replaceStrings [ "%r" ] [ "/run/user/${toString x}" ] y; in { options.profiles.browsing = { enable = lib.mkEnableOption "A profile that enables a browser for the GUI and the terminal"; hiDpi = lib.mkOption { type = lib.types.bool; default = false; description = '' Tweak the browsers for better readability on HiDPI screens ''; }; }; config = lib.mkIf cfg.enable { home.packages = with pkgs; [ firefox lynx ]; sops.secrets.kagi-query = { }; sops.secrets.kagi-session = { }; programs.qutebrowser = { enable = true; searchEngines = { g = "https://www.google.com/search?hl=en&q={}"; ddg = "https://www.duckduckgo.com/?q={}"; nw = "https://nixos.wiki/index.php?search={}"; ns = "https://search.nixos.org/options?channel=unstable&from=0size=50&sort=relevance&type=packages&query={}"; np = "https://search.nixos.org/packages?channel=unstable&from=0&size=50&sort=relevance&type=packages&query={}"; rd = "https://docs.rs/releases/search?query={}"; rp = "https://lib.rs/search?q={}"; }; quickmarks = { github = "https://github.com"; sourcehut = "https://sr.ht"; }; settings = import ./qutebrowser-settings.nix // { # mimeApps: open links in new window new_instance_open_target = "window"; } // lib.optionalAttrs (cfg.hiDpi) { qt.highdpi = true; fonts.default_size = "12pt"; }; extraConfig = '' with open('${fixSopsPrefix 1000 config.sops.secrets.kagi-query.path}') as f: c.url.searchengines['DEFAULT'] = f.readline() with open('${fixSopsPrefix 1000 config.sops.secrets.kagi-session.path}') as f: k_session = f.readline() c.url.default_page = k_session c.url.start_pages = k_session ''; }; xdg.mimeApps = lib.mkIf pkgs.stdenv.isLinux { enable = true; defaultApplications = { "x-scheme-handler/http" = [ "org.qutebrowser.qutebrowser.desktop" ]; "x-scheme-handler/https" = [ "org.qutebrowser.qutebrowser.desktop" ]; "text/html" = [ "org.qutebrowser.qutebrowser.desktop" ]; "x-scheme-handler/about" = [ "org.qutebrowser.qutebrowser.desktop" ]; "x-scheme-handler/unknown" = [ "org.qutebrowser.qutebrowser.desktop" ]; }; }; }; }