1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-05 02:39:45 +01:00

firefox: add finalPackage read-only option

When a user references config.programs.firefox.package in her/his
configuration, s·he will get a different path than what is in the
$PATH variable. To make it possible to get the same path, this commit
introduces the finalPackage read-only option.
This commit is contained in:
Damien Cassou 2023-11-01 21:36:40 +01:00 committed by Robert Helgesson
parent 691cbcc03a
commit d78f6693ee
No known key found for this signature in database
GPG key ID: 36BDAA14C2797E89

View file

@ -152,6 +152,27 @@ let
'' + concatStringsSep "\n" (mapAttrsToList mkMsg duplicates); '' + concatStringsSep "\n" (mapAttrsToList mkMsg duplicates);
}); });
wrapPackage = package:
let
# The configuration expected by the Firefox wrapper.
fcfg = { enableGnomeExtensions = cfg.enableGnomeExtensions; };
# A bit of hackery to force a config into the wrapper.
browserName =
package.browserName or (builtins.parseDrvName package.name).name;
# The configuration expected by the Firefox wrapper builder.
bcfg = setAttrByPath [ browserName ] fcfg;
in if package == null then
null
else if isDarwin then
package
else if versionAtLeast config.home.stateVersion "19.09" then
package.override (old: { cfg = old.cfg or { } // fcfg; })
else
(pkgs.wrapFirefox.override { config = bcfg; }) package { };
in { in {
meta.maintainers = [ maintainers.rycee maintainers.kira-bruneau ]; meta.maintainers = [ maintainers.rycee maintainers.kira-bruneau ];
@ -203,6 +224,12 @@ in {
''; '';
}; };
finalPackage = mkOption {
type = with types; nullOr package;
readOnly = true;
description = "Resulting Firefox package.";
};
profiles = mkOption { profiles = mkOption {
type = types.attrsOf (types.submodule ({ config, name, ... }: { type = types.attrsOf (types.submodule ({ config, name, ... }: {
options = { options = {
@ -620,24 +647,9 @@ in {
its example for how to do this. its example for how to do this.
''; '';
home.packages = let programs.firefox.finalPackage = wrapPackage cfg.package;
# The configuration expected by the Firefox wrapper.
fcfg = { enableGnomeExtensions = cfg.enableGnomeExtensions; };
# A bit of hackery to force a config into the wrapper. home.packages = lib.optional (cfg.finalPackage != null) cfg.finalPackage;
browserName = cfg.package.browserName or (builtins.parseDrvName
cfg.package.name).name;
# The configuration expected by the Firefox wrapper builder.
bcfg = setAttrByPath [ browserName ] fcfg;
package = if isDarwin then
cfg.package
else if versionAtLeast config.home.stateVersion "19.09" then
cfg.package.override (old: { cfg = old.cfg or { } // fcfg; })
else
(pkgs.wrapFirefox.override { config = bcfg; }) cfg.package { };
in lib.optional (cfg.package != null) package;
home.file = mkMerge ([{ home.file = mkMerge ([{
"${firefoxConfigPath}/profiles.ini" = "${firefoxConfigPath}/profiles.ini" =