nix_config/home/modules/firefox.nix

58 lines
1.4 KiB
Nix
Raw Normal View History

2025-01-28 19:28:28 +01:00
{
config,
lib,
pkgs,
...
}:
with lib; let
2025-01-31 15:28:46 +01:00
cfg = config.local.apps.firefox;
2025-01-28 19:28:28 +01:00
in {
2025-01-31 15:28:46 +01:00
options.local.apps.firefox = {
2025-01-28 19:28:28 +01:00
enable = mkEnableOption "firefox settings";
2025-01-31 15:24:40 +01:00
2025-01-28 19:28:28 +01:00
workspace = mkOption {
type = types.nullOr types.str;
default = null;
description = ''
2025-02-07 19:36:22 +01:00
i3 Workspace in which Firefox should open. If not set, Firefox will not open at startup
'';
};
makeDefaultBrowser = mkOption {
type = types.bool;
default = true;
description = ''
Take a guess
2025-01-28 19:28:28 +01:00
'';
};
};
2025-02-07 19:36:22 +01:00
config = mkIf cfg.enable (mkMerge [
{
programs.firefox.enable = true;
2025-01-28 19:28:28 +01:00
2025-02-07 19:36:22 +01:00
xsession.windowManager.i3.config.startup = optional (cfg.workspace != null) {
command = "${lib.getExe pkgs.i3-gaps} 'workspace ${cfg.workspace}; exec ${lib.getExe pkgs.firefox}'";
};
}
(mkIf cfg.makeDefaultBrowser {
xdg = {
mimeApps = {
enable = true;
defaultApplications = {
"text/html" = ["firefox"];
"text/uri-list" = ["firefox"];
"x-scheme-handler/http" = ["firefox"];
"x-scheme-handler/https" = ["firefox"];
"x-scheme-handler/about" = ["firefox"];
"x-scheme-handler/unknown" = ["firefox"];
};
2025-01-31 15:28:46 +01:00
};
};
2025-02-07 19:36:22 +01:00
home.sessionVariables.DEFAULT_BROWSER = "${lib.getExe pkgs.firefox}";
})
]);
2025-01-28 19:28:28 +01:00
}