mirror of
https://github.com/nix-community/home-manager
synced 2025-01-30 21:05:02 +01:00
firefox: avoid unnecessarily overriding package
When `cfg.package` is already wrapped, and wrapped without the `ExtensionSettings` key set, this would always add that key, even if its value was blank. This would result in `cfg.finalPackage` being a functionally-identical, but differently-input-addressed package. This is generally undesirable as it may result in multiple derivations being built, and also if the value of `cfg.package` is expected to be unchanged by the user (e.g. because they want it to be consistent between NixOS and HM configuration). Add a test to ensure this does not regress in the default case. Only test on newish stateVersion since the logic for `isWrapped` differs on older versions.
This commit is contained in:
parent
1b4f2a4816
commit
bd530df4e2
3 changed files with 33 additions and 6 deletions
|
@ -803,12 +803,13 @@ in {
|
||||||
finalPackage = wrapPackage cfg.package;
|
finalPackage = wrapPackage cfg.package;
|
||||||
|
|
||||||
policies = {
|
policies = {
|
||||||
ExtensionSettings = listToAttrs (map (lang:
|
ExtensionSettings = lib.mkIf (cfg.languagePacks != [ ]) (listToAttrs (map
|
||||||
nameValuePair "langpack-${lang}@firefox.mozilla.org" {
|
(lang:
|
||||||
installation_mode = "normal_installed";
|
nameValuePair "langpack-${lang}@firefox.mozilla.org" {
|
||||||
install_url =
|
installation_mode = "normal_installed";
|
||||||
"https://releases.mozilla.org/pub/firefox/releases/${cfg.package.version}/linux-x86_64/xpi/${lang}.xpi";
|
install_url =
|
||||||
}) cfg.languagePacks);
|
"https://releases.mozilla.org/pub/firefox/releases/${cfg.package.version}/linux-x86_64/xpi/${lang}.xpi";
|
||||||
|
}) cfg.languagePacks));
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
name:
|
name:
|
||||||
builtins.mapAttrs (test: module: import module [ "programs" name ]) {
|
builtins.mapAttrs (test: module: import module [ "programs" name ]) {
|
||||||
"${name}-deprecated-native-messenger" = ./deprecated-native-messenger.nix;
|
"${name}-deprecated-native-messenger" = ./deprecated-native-messenger.nix;
|
||||||
|
"${name}-final-package" = ./final-package.nix;
|
||||||
"${name}-policies" = ./policies.nix;
|
"${name}-policies" = ./policies.nix;
|
||||||
"${name}-profiles-bookmarks" = ./profiles/bookmarks;
|
"${name}-profiles-bookmarks" = ./profiles/bookmarks;
|
||||||
"${name}-profiles-containers" = ./profiles/containers;
|
"${name}-profiles-containers" = ./profiles/containers;
|
||||||
|
|
25
tests/modules/programs/firefox/final-package.nix
Normal file
25
tests/modules/programs/firefox/final-package.nix
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
modulePath:
|
||||||
|
{ config, lib, pkgs, ... }:
|
||||||
|
|
||||||
|
let
|
||||||
|
|
||||||
|
cfg = lib.getAttrFromPath modulePath config;
|
||||||
|
|
||||||
|
firefoxMockOverlay = import ./setup-firefox-mock-overlay.nix modulePath;
|
||||||
|
|
||||||
|
in {
|
||||||
|
imports = [ firefoxMockOverlay ];
|
||||||
|
|
||||||
|
config = lib.mkIf config.test.enableBig
|
||||||
|
(lib.setAttrByPath modulePath { enable = true; } // {
|
||||||
|
home.stateVersion = "19.09";
|
||||||
|
|
||||||
|
nmt.script = ''
|
||||||
|
package=${cfg.package}
|
||||||
|
finalPackage=${cfg.finalPackage}
|
||||||
|
if [[ $package != $finalPackage ]]; then
|
||||||
|
fail "Expected finalPackage ($finalPackage) to equal package ($package)"
|
||||||
|
fi
|
||||||
|
'';
|
||||||
|
});
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue