refactor(home): replace custom Firefox module with home-manager's new mkFirefoxModule
- replaced core module with `mkFirefoxModule` from home-manager - `mkFirefoxModuleCompat` was created as a wrapper around `mkFirefoxModule` for compatibility with other Firefox-based browser packages such as Tor/Mullvad Browser - profile binary & desktop file creation moved into `mkFirefoxProfileBinModule`
This commit is contained in:
parent
921b59fa40
commit
8beb27389a
6 changed files with 212 additions and 783 deletions
67
home/modules/firefox/mkFirefoxModuleCompat.nix
Normal file
67
home/modules/firefox/mkFirefoxModuleCompat.nix
Normal file
|
@ -0,0 +1,67 @@
|
|||
{ modulePath, ... }@moduleArgs:
|
||||
|
||||
{
|
||||
inputs,
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
|
||||
let
|
||||
mkFirefoxModule = import "${inputs.home-manager.outPath}/modules/programs/firefox/mkFirefoxModule.nix";
|
||||
|
||||
cfg = lib.getAttrFromPath modulePath config;
|
||||
|
||||
# HINT home-manager's Firefox module uses a read-only `finalPackage` option
|
||||
# that creates a wrapper around `package`. However, this wrapper is not
|
||||
# compatible with all Firefox-based browser packages. Thus, we adjust the module
|
||||
# to always set `finalPackage` to `package` & remove unsupported options.
|
||||
fixFirefoxModuleCompat =
|
||||
module:
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
let
|
||||
optionsPath = [ "options" ] ++ modulePath;
|
||||
configPath = [
|
||||
"config"
|
||||
"content" # due to mkIf
|
||||
] ++ modulePath;
|
||||
in
|
||||
lib.updateManyAttrsByPath
|
||||
[
|
||||
{
|
||||
path = optionsPath ++ [ "languagePacks" ];
|
||||
update = old: { };
|
||||
}
|
||||
{
|
||||
path = configPath ++ [ "finalPackage" ];
|
||||
update = old: cfg.package;
|
||||
}
|
||||
{
|
||||
path = configPath ++ [ "policies" ];
|
||||
update = old: { };
|
||||
}
|
||||
]
|
||||
(module {
|
||||
inherit config lib pkgs;
|
||||
});
|
||||
in
|
||||
{
|
||||
imports = [
|
||||
(fixFirefoxModuleCompat (mkFirefoxModule moduleArgs))
|
||||
];
|
||||
|
||||
options = lib.setAttrByPath modulePath { };
|
||||
|
||||
config = lib.mkIf cfg.enable (
|
||||
{ }
|
||||
// lib.setAttrByPath modulePath {
|
||||
# Tor & Mullvad Browser don't support profile version 2 yet
|
||||
profileVersion = null;
|
||||
}
|
||||
);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue