This module should provide similar functionality to the firefox module in home-manager. Some notable differences between the two include: * home-manager configures a single browser. This means that any configuration that cannot be done on a per-profile basis is shared between all profiles. This module configures a new copy of the browser for every profile, ensuring that *all* configuration can be on a per-profile basis. This might be seen as insanity in a regular distro, but in NixOS this is trivial to do and requires no extra storage space. * home-manager modifies files in the user's directory to configure things such as extensions and search engines. This module avoids that when possible by pushing configuration into policies and preferences at a browser level. This is much nicer for impermanence-based systems.
91 lines
2 KiB
Nix
91 lines
2 KiB
Nix
sLib: fork:
|
|
{
|
|
config,
|
|
lib,
|
|
pkgs,
|
|
...
|
|
}:
|
|
|
|
let
|
|
info =
|
|
{
|
|
"firefox" = {
|
|
name = "firefox";
|
|
base = pkgs.firefox-unwrapped;
|
|
binName = "firefox";
|
|
configPath = ".mozilla/firefox";
|
|
};
|
|
"librewolf" = {
|
|
name = "librewolf";
|
|
base = pkgs.librewolf-unwrapped;
|
|
binName = "librewolf";
|
|
configPath = ".librewolf";
|
|
};
|
|
"floorp" = {
|
|
name = "floorp";
|
|
base = pkgs.floorp-bin-unwrapped;
|
|
binName = "floorp"; # TODO: test
|
|
configPath = ".floorp"; # TODO: test
|
|
};
|
|
}
|
|
.${fork};
|
|
|
|
cfg = config.hylonix.${info.name};
|
|
geckoLib = import ./gecko-lib {
|
|
inherit
|
|
geckoLib
|
|
info
|
|
lib
|
|
pkgs
|
|
sLib
|
|
;
|
|
};
|
|
|
|
finalConfig = geckoLib.profiles.evaluateAllProfiles cfg.profiles;
|
|
|
|
buildFinal =
|
|
profile: settings:
|
|
let
|
|
pkg = (
|
|
pkgs.wrapFirefox info.base {
|
|
extraPolicies = settings.policies;
|
|
extraPrefs = settings.prefs;
|
|
}
|
|
);
|
|
in
|
|
{
|
|
package = pkg;
|
|
command = "${pkg}/bin/${info.binName} -P ${profile}";
|
|
};
|
|
in
|
|
{
|
|
options.hylonix.${info.name} = {
|
|
enable = lib.mkEnableOption fork;
|
|
|
|
final = lib.mkOption {
|
|
type = lib.types.attrsOf (
|
|
lib.types.submodule {
|
|
options = {
|
|
package = lib.mkOption { type = lib.types.package; };
|
|
command = lib.mkOption { type = lib.types.str; };
|
|
};
|
|
}
|
|
);
|
|
visible = false;
|
|
readOnly = true;
|
|
description = "Resulting browser information for this profile.";
|
|
};
|
|
|
|
profiles = geckoLib.profiles.options;
|
|
}; # end options
|
|
|
|
config = lib.mkIf cfg.enable {
|
|
inherit (finalConfig) assertions warnings;
|
|
|
|
hylonix.${info.name}.final = lib.mapAttrs buildFinal finalConfig.profiles;
|
|
|
|
home.file = builtins.listToAttrs finalConfig.files;
|
|
|
|
home.packages = [ cfg.final.${geckoLib.profiles.getDefaultProfileName cfg.profiles}.package ];
|
|
}; # end config
|
|
}
|