1
0
Fork 0
mirror of https://github.com/nix-community/home-manager.git synced 2025-04-14 00:07:15 +00:00
home-manager/tests/modules/programs/firefox/profiles/bookmarks/default.nix
Ihar Hrachyshka d3ebdb59a3 tests: Enable firefox tests for darwin
This change also removes checks for MOZ_APP_LAUNCHER set for wrapped
package: the wrapped binary is in a different location on Darwin; but
the check seems out of place for Home Manager since it doesn't control
exact variables set by nixpkgs package.

This change also removes handling of state version < 19.09 when the
firefox package was not wrapped. It's time to clean up.

Signed-off-by: Ihar Hrachyshka <ihar.hrachyshka@gmail.com>
2025-03-19 10:15:13 -04:00

96 lines
2.4 KiB
Nix

modulePath:
{ config, lib, pkgs, ... }:
let
cfg = lib.getAttrFromPath modulePath config;
firefoxMockOverlay = import ../../setup-firefox-mock-overlay.nix modulePath;
withName = path:
pkgs.substituteAll {
src = path;
name = cfg.wrappedPackageName;
};
in {
imports = [ firefoxMockOverlay ];
config = lib.mkIf config.test.enableBig (lib.setAttrByPath modulePath {
enable = true;
profiles.bookmarks = {
settings = { "general.smoothScroll" = false; };
bookmarks = [
{
toolbar = true;
bookmarks = [{
name = "Home Manager";
url = "https://wiki.nixos.org/wiki/Home_Manager";
}];
}
{
name = "wikipedia";
tags = [ "wiki" ];
keyword = "wiki";
url = "https://en.wikipedia.org/wiki/Special:Search?search=%s&go=Go";
}
{
name = "kernel.org";
url = "https://www.kernel.org";
}
{
name = "Nix sites";
bookmarks = [
{
name = "homepage";
url = "https://nixos.org/";
}
{
name = "wiki";
tags = [ "wiki" "nix" ];
url = "https://wiki.nixos.org/";
}
{
name = "Nix sites";
bookmarks = [
{
name = "homepage";
url = "https://nixos.org/";
}
{
name = "wiki";
url = "https://wiki.nixos.org/";
}
];
}
];
}
];
};
} // {
nmt.script = let
isDarwin = pkgs.stdenv.hostPlatform.isDarwin;
profilePath = if isDarwin then
"Library/Application Support/Firefox/Profiles"
else
".mozilla/firefox";
in ''
bookmarksUserJs=$(normalizeStorePaths \
"home-files/${profilePath}/bookmarks/user.js")
assertFileContent \
$bookmarksUserJs \
${withName ./expected-bookmarks-user.js}
bookmarksFile="$(sed -n \
'/browser.bookmarks.file/ {s|^.*\(/nix/store[^"]*\).*|\1|;p}' \
$TESTED/home-files/'${profilePath}'/bookmarks/user.js)"""
echo "bookmarksFile: $bookmarksFile"
assertFileContent \
$bookmarksFile \
${./expected-bookmarks.html}
'';
});
}