mirror of
https://github.com/nix-community/home-manager
synced 2024-11-27 05:29:46 +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:
parent
691cbcc03a
commit
d78f6693ee
1 changed files with 29 additions and 17 deletions
|
@ -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" =
|
||||||
|
|
Loading…
Reference in a new issue