- 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`
67 lines
1.6 KiB
Nix
67 lines
1.6 KiB
Nix
{
|
|
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 { }
|
|
);
|
|
}
|