update firefox module

This commit is contained in:
Nathan Anderson 2026-02-15 21:56:24 -07:00
parent 509a02d847
commit 95eb2f49a6

View File

@ -1,9 +1,17 @@
{lib, config, pkgs, inputs, options, ...}:
{
lib,
config,
pkgs,
inputs,
options,
...
}:
let
cfg = config.firefoxApp;
# Check if stylix home-manager module is loaded by checking for the firefox target option
# Only check options (not config) to avoid infinite recursion during module evaluation
hasStylixFirefox = (options ? stylix) && (options.stylix ? targets) && (options.stylix.targets ? firefox);
hasStylixFirefox =
(options ? stylix) && (options.stylix ? targets) && (options.stylix.targets ? firefox);
in
{
# imports = [
@ -13,7 +21,9 @@ in
options.firefoxApp = {
enable = lib.mkEnableOption "enable firefox browser";
};
config = lib.mkIf cfg.enable (lib.mkMerge ([
config = lib.mkIf cfg.enable (
lib.mkMerge (
[
# Firefox configuration
{
programs.firefox = {
@ -25,62 +35,98 @@ in
id = 0;
name = "default";
isDefault = true;
extensions.packages = with pkgs; [
extensions = {
force = true;
packages = with pkgs; [
nur.repos.rycee.firefox-addons.darkreader
nur.repos.rycee.firefox-addons.keepassxc-browser
nur.repos.crazazy.firefox-addons.ublock-origin
nur.repos.bandithedoge.firefoxAddons.stylus
];
};
search = {
# Replace default firefox search engine config with this one
force = true;
default = "Kagi";
engines = {
"Kagi" = {
urls = [{
urls = [
{
template = "https://kagi.com/search?q={searchTerms}";
}];
}
];
};
"Nix Packages" = {
urls = [{
urls = [
{
template = "https://search.nixos.org/packages";
params = [
{ name = "type"; value = "packages"; }
{ name = "query"; value = "{searchTerms}"; }
{
name = "type";
value = "packages";
}
{
name = "query";
value = "{searchTerms}";
}
];
}
];
}];
icon = "${pkgs.nixos-icons}/share/icons/hicolor/scalable/apps/nix-snowflake.svg";
definedAliases = [ "@np" ];
};
"NixOS Wiki" = {
urls = [{
urls = [
{
template = "https://wiki.nixos.org/w/index.php";
params = [
{ name = "search"; value = "{searchTerms}"; }
{
name = "search";
value = "{searchTerms}";
}
];
}
];
}];
icon = "${pkgs.nixos-icons}/share/icons/hicolor/scalable/apps/nix-snowflake.svg";
definedAliases = [ "@nix" ];
};
"MySQL Docs" = {
urls = [{
urls = [
{
template = "https://dev.mysql.com/doc/search";
params = [
{ name = "d"; value = "371"; }
{ name = "p"; value = "1"; }
{ name = "q"; value = "{searchTerms}"; }
{
name = "d";
value = "371";
}
{
name = "p";
value = "1";
}
{
name = "q";
value = "{searchTerms}";
}
];
}
];
}];
definedAliases = [ "@mysql" ];
};
"SQLite Docs" = {
urls = [{
urls = [
{
template = "https://www.sqlite.org/search?s=d&q=strict";
params = [
{ name = "s"; value = "d"; }
{ name = "q"; value = "{searchTerms}"; }
{
name = "s";
value = "d";
}
{
name = "q";
value = "{searchTerms}";
}
];
}
];
}];
definedAliases = [ "@sqlite" ];
};
};
@ -115,9 +161,12 @@ in
};
};
}
] ++ lib.optional hasStylixFirefox {
]
++ lib.optional hasStylixFirefox {
# Stylix integration (only if stylix module is loaded)
# Uses mkIf to check autoEnable at runtime, avoiding infinite recursion
stylix.targets.firefox.profileNames = lib.mkIf config.stylix.autoEnable [ "default" ];
}));
}
)
);
}