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/mkFirefoxProfileBinModule.nix
Normal file
67
home/modules/firefox/mkFirefoxProfileBinModule.nix
Normal file
|
@ -0,0 +1,67 @@
|
|||
{
|
||||
modulePath,
|
||||
name,
|
||||
packageName,
|
||||
isSecure ? false,
|
||||
}:
|
||||
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
|
||||
let
|
||||
appName = name;
|
||||
cfg = lib.getAttrFromPath modulePath config;
|
||||
|
||||
mkProfileBin =
|
||||
profileName: profile:
|
||||
let
|
||||
pname = "${packageName}-${profileName}";
|
||||
scriptBin = pkgs.writeScriptBin pname ''
|
||||
${packageName} -P "${profileName}" --name="${pname}" $@
|
||||
'';
|
||||
desktopFile = pkgs.makeDesktopItem {
|
||||
name = pname;
|
||||
exec = "${scriptBin}/bin/${pname} %U";
|
||||
icon = packageName;
|
||||
extraConfig.StartupWMClass = pname;
|
||||
desktopName = "${appName} (${profileName})";
|
||||
genericName = "Web Browser";
|
||||
categories = [
|
||||
"Network"
|
||||
"WebBrowser"
|
||||
] ++ lib.optional isSecure "Security";
|
||||
};
|
||||
in
|
||||
pkgs.runCommand pname { } ''
|
||||
mkdir -p $out/{bin,share}
|
||||
cp -r ${scriptBin}/bin/${pname} $out/bin/${pname}
|
||||
cp -r ${desktopFile}/share/applications $out/share/applications
|
||||
'';
|
||||
in
|
||||
{
|
||||
options = lib.setAttrByPath modulePath {
|
||||
createProfileBins = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
default = false;
|
||||
description = ''
|
||||
When enabled installs a binary for all non-default profiles named `${packageName}-''${profile}`.
|
||||
This also includes a `.desktop` file that is configured to show separate icons (on GNOME at least).
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable (
|
||||
{
|
||||
home.packages =
|
||||
if cfg.createProfileBins then
|
||||
(lib.mapAttrsToList mkProfileBin) (lib.filterAttrs (_: p: !p.isDefault) cfg.profiles)
|
||||
else
|
||||
[ ];
|
||||
}
|
||||
// lib.setAttrByPath modulePath { }
|
||||
);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue