From 2bfcb22a2229b2e53a839ceb35057ff3b9fd92a2 Mon Sep 17 00:00:00 2001 From: Fabian Montero Date: Fri, 7 Feb 2025 13:10:02 -0600 Subject: [PATCH] add firefox module --- hm/default.nix | 11 ++++++- hm/programs/default.nix | 10 ++++++ hm/programs/firefox/default.nix | 57 +++++++++++++++++++++++++++++++++ 3 files changed, 77 insertions(+), 1 deletion(-) create mode 100644 hm/programs/default.nix create mode 100644 hm/programs/firefox/default.nix diff --git a/hm/default.nix b/hm/default.nix index 0967ef4..dd56cf2 100644 --- a/hm/default.nix +++ b/hm/default.nix @@ -1 +1,10 @@ -{} +{ + config, + lib, + pkgs, + ... +}: { + imports = [ + ./programs + ]; +} diff --git a/hm/programs/default.nix b/hm/programs/default.nix new file mode 100644 index 0000000..e95efb7 --- /dev/null +++ b/hm/programs/default.nix @@ -0,0 +1,10 @@ +{ + config, + lib, + pkgs, + ... +}: { + imports = [ + ./firefox + ]; +} diff --git a/hm/programs/firefox/default.nix b/hm/programs/firefox/default.nix new file mode 100644 index 0000000..c6907a7 --- /dev/null +++ b/hm/programs/firefox/default.nix @@ -0,0 +1,57 @@ +{ + config, + lib, + pkgs, + ... +}: +with lib; let + cfg = config.options.trivium.programs.firefox; +in { + options.options.trivium.programs.firefox = { + enable = mkEnableOption "firefox settings"; + + workspace = mkOption { + type = types.nullOr types.str; + default = null; + description = '' + 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 + ''; + }; + }; + + config = mkIf cfg.enable (mkMerge [ + { + programs.firefox.enable = true; + + 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"]; + }; + }; + }; + + home.sessionVariables.DEFAULT_BROWSER = "${lib.getExe pkgs.firefox}"; + }) + ]); +}