Make firefox module compatible with nixos hosts

This commit is contained in:
Yan Lin 2025-09-12 23:15:08 +02:00
parent 3e40d04572
commit c85ea77b73
2 changed files with 175 additions and 150 deletions

View file

@ -22,6 +22,12 @@
nixpkgs.config.allowUnfree = true; nixpkgs.config.allowUnfree = true;
# Firefox configuration
programs.firefox-custom = {
enable = true;
package = null; # Use system Firefox on Darwin
};
home.username = "yanlin"; home.username = "yanlin";
home.homeDirectory = "/Users/yanlin"; home.homeDirectory = "/Users/yanlin";
home.stateVersion = "24.05"; home.stateVersion = "24.05";

View file

@ -1,6 +1,24 @@
{ config, pkgs, lib, ... }@args: { config, pkgs, lib, ... }@args:
with lib;
let
cfg = config.programs.firefox-custom;
in
{ {
options.programs.firefox-custom = {
enable = mkEnableOption "Firefox browser configuration";
package = mkOption {
type = types.nullOr types.package;
default = null;
example = "pkgs.firefox";
description = "Firefox package to use. Set to null on Darwin to use system Firefox, or pkgs.firefox on NixOS.";
};
};
config = mkIf cfg.enable {
# Create userChrome.css to hide Firefox View button # Create userChrome.css to hide Firefox View button
home.file."${config.home.homeDirectory}/.mozilla/firefox/yanlin/chrome/userChrome.css".text = '' home.file."${config.home.homeDirectory}/.mozilla/firefox/yanlin/chrome/userChrome.css".text = ''
/* Hide Firefox View button */ /* Hide Firefox View button */
@ -17,7 +35,7 @@
programs.firefox = { programs.firefox = {
enable = true; enable = true;
package = null; package = cfg.package;
profiles.yanlin = { profiles.yanlin = {
id = 0; id = 0;
@ -159,4 +177,5 @@
}; };
}; };
}; };
};
} }