1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-23 03:29:45 +01:00

firefox: support firefox derivatives

Adds support for Firefox forks by introducing methods that create
generic configs and options. Additional configs and options can be
added in separate modules.
This commit is contained in:
bricked 2024-03-13 00:20:41 +01:00 committed by Robert Helgesson
parent 587fcca66e
commit 792757f643
No known key found for this signature in database
GPG key ID: 96E745BD17AA17ED
14 changed files with 1356 additions and 1203 deletions

View file

@ -49,6 +49,12 @@
github = "bertof"; github = "bertof";
githubId = 9915675; githubId = 9915675;
}; };
bricked = {
name = "Bricked";
email = "hello@bricked.dev";
github = "brckd";
githubId = 92804487;
};
CarlosLoboxyz = { CarlosLoboxyz = {
name = "Carlos Lobo"; name = "Carlos Lobo";
email = "86011416+CarlosLoboxyz@users.noreply.github.com"; email = "86011416+CarlosLoboxyz@users.noreply.github.com";

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -189,7 +189,7 @@ in import nmtSrc {
./modules/programs/bemenu ./modules/programs/bemenu
./modules/programs/borgmatic ./modules/programs/borgmatic
./modules/programs/boxxy ./modules/programs/boxxy
./modules/programs/firefox ./modules/programs/firefox/firefox.nix
./modules/programs/foot ./modules/programs/foot
./modules/programs/freetube ./modules/programs/freetube
./modules/programs/fuzzel ./modules/programs/fuzzel

View file

@ -1,27 +1,32 @@
modulePath:
{ config, lib, ... }: { config, lib, ... }:
{ with lib;
imports = [ ./setup-firefox-mock-overlay.nix ];
config = lib.mkIf config.test.enableBig { let
firefoxMockOverlay = import ./setup-firefox-mock-overlay.nix modulePath;
in {
imports = [ firefoxMockOverlay ];
config = mkIf config.test.enableBig ({
test.asserts.assertions.expected = test.asserts.assertions.expected =
[ "Container id must be smaller than 4294967294 (2^32 - 2)" ]; [ "Container id must be smaller than 4294967294 (2^32 - 2)" ];
} // setAttrByPath modulePath {
enable = true;
programs.firefox = { profiles.my-profile = {
enable = true; isDefault = true;
id = 1;
profiles.my-profile = { containers = {
isDefault = true; "shopping" = {
id = 1; id = 4294967294;
color = "blue";
containers = { icon = "circle";
"shopping" = {
id = 4294967294;
color = "blue";
icon = "circle";
};
}; };
}; };
}; };
}; });
} }

View file

@ -1,9 +0,0 @@
{
firefox-profile-settings = ./profile-settings.nix;
firefox-state-version-19_09 = ./state-version-19_09.nix;
firefox-deprecated-native-messenger = ./deprecated-native-messenger.nix;
firefox-duplicate-profile-ids = ./duplicate-profile-ids.nix;
firefox-duplicate-container-ids = ./duplicate-container-ids.nix;
firefox-container-id-out-of-range = ./container-id-out-of-range.nix;
firefox-policies = ./policies.nix;
}

View file

@ -1,21 +1,26 @@
{ config, lib, pkgs, ... }: modulePath:
{ config, lib, ... }:
with lib; with lib;
{ let
imports = [ ./setup-firefox-mock-overlay.nix ];
config = lib.mkIf config.test.enableBig { moduleName = concatStringsSep "." modulePath;
programs.firefox = {
enable = true;
enableGnomeExtensions = true;
};
firefoxMockOverlay = import ./setup-firefox-mock-overlay.nix modulePath;
in {
imports = [ firefoxMockOverlay ];
config = mkIf config.test.enableBig (setAttrByPath modulePath {
enable = true;
enableGnomeExtensions = true;
} // {
test.asserts.warnings.expected = ['' test.asserts.warnings.expected = [''
Using 'programs.firefox.enableGnomeExtensions' has been deprecated and Using '${moduleName}.enableGnomeExtensions' has been deprecated and
will be removed in the future. Please change to overriding the package will be removed in the future. Please change to overriding the package
configuration using 'programs.firefox.package' instead. You can refer to configuration using '${moduleName}.package' instead. You can refer to
its example for how to do this. its example for how to do this.
'']; ''];
}; });
} }

View file

@ -1,35 +1,42 @@
modulePath:
{ config, lib, ... }: { config, lib, ... }:
{ with lib;
imports = [ ./setup-firefox-mock-overlay.nix ];
config = lib.mkIf config.test.enableBig { let
cfg = getAttrFromPath modulePath config;
firefoxMockOverlay = import ./setup-firefox-mock-overlay.nix modulePath;
in {
imports = [ firefoxMockOverlay ];
config = mkIf config.test.enableBig ({
test.asserts.assertions.expected = ['' test.asserts.assertions.expected = [''
Must not have a Firefox container with an existing ID but Must not have a ${cfg.name} container with an existing ID but
- ID 9 is used by dangerous, shopping'']; - ID 9 is used by dangerous, shopping''];
} // setAttrByPath modulePath {
enable = true;
programs.firefox = { profiles = {
enable = true; my-profile = {
isDefault = true;
id = 1;
profiles = { containers = {
my-profile = { "shopping" = {
isDefault = true; id = 9;
id = 1; color = "blue";
icon = "circle";
containers = { };
"shopping" = { "dangerous" = {
id = 9; id = 9;
color = "blue"; color = "red";
icon = "circle"; icon = "circle";
};
"dangerous" = {
id = 9;
color = "red";
icon = "circle";
};
}; };
}; };
}; };
}; };
}; });
} }

View file

@ -1,23 +1,30 @@
modulePath:
{ config, lib, ... }: { config, lib, ... }:
{ with lib;
imports = [ ./setup-firefox-mock-overlay.nix ];
config = lib.mkIf config.test.enableBig { let
cfg = getAttrFromPath modulePath config;
firefoxMockOverlay = import ./setup-firefox-mock-overlay.nix modulePath;
in {
imports = [ firefoxMockOverlay ];
config = mkIf config.test.enableBig ({
test.asserts.assertions.expected = ['' test.asserts.assertions.expected = [''
Must not have a Firefox profile with an existing ID but Must not have a ${cfg.name} profile with an existing ID but
- ID 1 is used by first, second'']; - ID 1 is used by first, second''];
} // setAttrByPath modulePath {
enable = true;
programs.firefox = { profiles = {
enable = true; first = {
isDefault = true;
profiles = { id = 1;
first = {
isDefault = true;
id = 1;
};
second = { id = 1; };
}; };
second = { id = 1; };
}; };
}; });
} }

View file

@ -0,0 +1,11 @@
let name = "firefox";
in builtins.mapAttrs (test: module: import module [ "programs" name ]) {
"${name}-profile-settings" = ./profile-settings.nix;
"${name}-state-version-19_09" = ./state-version-19_09.nix;
"${name}-deprecated-native-messenger" = ./deprecated-native-messenger.nix;
"${name}-duplicate-profile-ids" = ./duplicate-profile-ids.nix;
"${name}-duplicate-container-ids" = ./duplicate-container-ids.nix;
"${name}-container-id-out-of-range" = ./container-id-out-of-range.nix;
"${name}-policies" = ./policies.nix;
}

View file

@ -1,22 +1,29 @@
modulePath:
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
{ with lib;
imports = [ ./setup-firefox-mock-overlay.nix ];
config = lib.mkIf config.test.enableBig { let
cfg = getAttrFromPath modulePath config;
firefoxMockOverlay = import ./setup-firefox-mock-overlay.nix modulePath;
in {
imports = [ firefoxMockOverlay ];
config = mkIf config.test.enableBig ({
home.stateVersion = "23.05"; home.stateVersion = "23.05";
} // setAttrByPath modulePath {
programs.firefox = { enable = true;
enable = true; policies = { BlockAboutConfig = true; };
policies = { BlockAboutConfig = true; }; package = pkgs.${cfg.wrappedPackageName}.override {
package = pkgs.firefox.override { extraPolicies = { DownloadDirectory = "/foo"; };
extraPolicies = { DownloadDirectory = "/foo"; };
};
}; };
}) // {
nmt.script = '' nmt.script = ''
jq=${lib.getExe pkgs.jq} jq=${lib.getExe pkgs.jq}
config_file="${config.programs.firefox.finalPackage}/lib/firefox/distribution/policies.json" config_file="${cfg.finalPackage}/lib/${cfg.wrappedPackageName}/distribution/policies.json"
assertFileExists "$config_file" assertFileExists "$config_file"

View file

@ -1,177 +1,184 @@
modulePath:
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
{ with lib;
imports = [ ./setup-firefox-mock-overlay.nix ];
config = lib.mkIf config.test.enableBig { let
programs.firefox = {
enable = true;
profiles.basic.isDefault = true;
profiles.test = { cfg = getAttrFromPath modulePath config;
id = 1;
settings = { firefoxMockOverlay = import ./setup-firefox-mock-overlay.nix modulePath;
"general.smoothScroll" = false;
"browser.newtabpage.pinned" = [{ in {
title = "NixOS"; imports = [ firefoxMockOverlay ];
url = "https://nixos.org";
config = mkIf config.test.enableBig (setAttrByPath modulePath {
enable = true;
profiles.basic.isDefault = true;
profiles.test = {
id = 1;
settings = {
"general.smoothScroll" = false;
"browser.newtabpage.pinned" = [{
title = "NixOS";
url = "https://nixos.org";
}];
};
};
profiles.bookmarks = {
id = 2;
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/";
}
];
}
];
}
];
};
profiles.bookmarks = { profiles.search = {
id = 2; id = 3;
settings = { "general.smoothScroll" = false; }; search = {
bookmarks = [ force = true;
{ default = "Google";
toolbar = true; privateDefault = "DuckDuckGo";
bookmarks = [{ order = [ "Nix Packages" "NixOS Wiki" ];
name = "Home Manager"; engines = {
url = "https://wiki.nixos.org/wiki/Home_Manager"; "Nix Packages" = {
urls = [{
template = "https://search.nixos.org/packages";
params = [
{
name = "type";
value = "packages";
}
{
name = "query";
value = "{searchTerms}";
}
];
}]; }];
}
{
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/";
}
];
}
];
}
];
};
profiles.search = { icon =
id = 3; "/run/current-system/sw/share/icons/hicolor/scalable/apps/nix-snowflake.svg";
search = {
force = true;
default = "Google";
privateDefault = "DuckDuckGo";
order = [ "Nix Packages" "NixOS Wiki" ];
engines = {
"Nix Packages" = {
urls = [{
template = "https://search.nixos.org/packages";
params = [
{
name = "type";
value = "packages";
}
{
name = "query";
value = "{searchTerms}";
}
];
}];
icon = definedAliases = [ "@np" ];
"/run/current-system/sw/share/icons/hicolor/scalable/apps/nix-snowflake.svg";
definedAliases = [ "@np" ];
};
"NixOS Wiki" = {
urls = [{
template =
"https://wiki.nixos.org/index.php?search={searchTerms}";
}];
iconUpdateURL = "https://wiki.nixos.org/favicon.png";
updateInterval = 24 * 60 * 60 * 1000;
definedAliases = [ "@nw" ];
};
"Bing".metaData.hidden = true;
"Google".metaData.alias = "@g";
}; };
"NixOS Wiki" = {
urls = [{
template =
"https://wiki.nixos.org/index.php?search={searchTerms}";
}];
iconUpdateURL = "https://wiki.nixos.org/favicon.png";
updateInterval = 24 * 60 * 60 * 1000;
definedAliases = [ "@nw" ];
};
"Bing".metaData.hidden = true;
"Google".metaData.alias = "@g";
}; };
}; };
};
profiles.searchWithoutDefault = { profiles.searchWithoutDefault = {
id = 4; id = 4;
search = { search = {
force = true; force = true;
order = [ "Google" "Nix Packages" ]; order = [ "Google" "Nix Packages" ];
engines = { engines = {
"Nix Packages" = { "Nix Packages" = {
urls = [{ urls = [{
template = "https://search.nixos.org/packages"; template = "https://search.nixos.org/packages";
params = [ params = [
{ {
name = "type"; name = "type";
value = "packages"; value = "packages";
} }
{ {
name = "query"; name = "query";
value = "{searchTerms}"; value = "{searchTerms}";
} }
]; ];
}]; }];
definedAliases = [ "@np" ]; definedAliases = [ "@np" ];
};
};
};
};
profiles.containers = {
id = 5;
containers = {
"shopping" = {
id = 6;
icon = "circle";
color = "yellow";
}; };
}; };
}; };
}; };
profiles.containers = {
id = 5;
containers = {
"shopping" = {
id = 6;
icon = "circle";
color = "yellow";
};
};
};
} // {
nmt.script = '' nmt.script = ''
assertFileRegex \ assertFileRegex \
home-path/bin/firefox \ home-path/bin/${cfg.wrappedPackageName} \
MOZ_APP_LAUNCHER MOZ_APP_LAUNCHER
assertDirectoryExists home-files/.mozilla/firefox/basic assertDirectoryExists home-files/${cfg.configPath}/basic
assertFileContent \ assertFileContent \
home-files/.mozilla/firefox/test/user.js \ home-files/${cfg.configPath}/test/user.js \
${./profile-settings-expected-user.js} ${./profile-settings-expected-user.js}
assertFileContent \ assertFileContent \
home-files/.mozilla/firefox/containers/containers.json \ home-files/${cfg.configPath}/containers/containers.json \
${./profile-settings-expected-containers.json} ${./profile-settings-expected-containers.json}
bookmarksUserJs=$(normalizeStorePaths \ bookmarksUserJs=$(normalizeStorePaths \
home-files/.mozilla/firefox/bookmarks/user.js) home-files/${cfg.configPath}/bookmarks/user.js)
assertFileContent \ assertFileContent \
$bookmarksUserJs \ $bookmarksUserJs \
@ -179,7 +186,7 @@
bookmarksFile="$(sed -n \ bookmarksFile="$(sed -n \
'/browser.bookmarks.file/ {s|^.*\(/nix/store[^"]*\).*|\1|;p}' \ '/browser.bookmarks.file/ {s|^.*\(/nix/store[^"]*\).*|\1|;p}' \
$TESTED/home-files/.mozilla/firefox/bookmarks/user.js)" $TESTED/home-files/${cfg.configPath}/bookmarks/user.js)"
assertFileContent \ assertFileContent \
$bookmarksFile \ $bookmarksFile \
@ -197,12 +204,12 @@
} }
assertFirefoxSearchContent \ assertFirefoxSearchContent \
home-files/.mozilla/firefox/search/search.json.mozlz4 \ home-files/${cfg.configPath}/search/search.json.mozlz4 \
${./profile-settings-expected-search.json} ${./profile-settings-expected-search.json}
assertFirefoxSearchContent \ assertFirefoxSearchContent \
home-files/.mozilla/firefox/searchWithoutDefault/search.json.mozlz4 \ home-files/${cfg.configPath}/searchWithoutDefault/search.json.mozlz4 \
${./profile-settings-expected-search-without-default.json} ${./profile-settings-expected-search-without-default.json}
''; '';
}; });
} }

View file

@ -1,16 +1,24 @@
{ pkgs, ... }: modulePath:
{ config, lib, pkgs, ... }:
{ with lib;
let
cfg = getAttrFromPath modulePath config;
in {
nixpkgs.overlays = [ nixpkgs.overlays = [
(self: super: { (self: super: {
firefox-unwrapped = pkgs.runCommandLocal "firefox-0" { "${cfg.wrappedPackageName}-unwrapped" =
meta.description = "I pretend to be Firefox"; pkgs.runCommandLocal "${cfg.wrappedPackageName}-0" {
passthru.gtk3 = null; meta.description = "I pretend to be ${cfg.name}";
} '' passthru.gtk3 = null;
mkdir -p "$out"/{bin,lib} } ''
touch "$out/bin/firefox" mkdir -p "$out"/{bin,lib}
chmod 755 "$out/bin/firefox" touch "$out/bin/${cfg.wrappedPackageName}"
''; chmod 755 "$out/bin/${cfg.wrappedPackageName}"
'';
chrome-gnome-shell = chrome-gnome-shell =
pkgs.runCommandLocal "dummy-chrome-gnome-shell" { } '' pkgs.runCommandLocal "dummy-chrome-gnome-shell" { } ''

View file

@ -1,19 +1,24 @@
modulePath:
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
with lib; with lib;
{ let
imports = [ ./setup-firefox-mock-overlay.nix ];
config = lib.mkIf config.test.enableBig { cfg = getAttrFromPath modulePath config;
firefoxMockOverlay = import ./setup-firefox-mock-overlay.nix modulePath;
in {
imports = [ firefoxMockOverlay ];
config = lib.mkIf config.test.enableBig ({
home.stateVersion = "19.09"; home.stateVersion = "19.09";
} // setAttrByPath modulePath { enable = true; } // {
programs.firefox.enable = true;
nmt.script = '' nmt.script = ''
assertFileRegex \ assertFileRegex \
home-path/bin/firefox \ home-path/bin/${cfg.wrappedPackageName} \
MOZ_APP_LAUNCHER MOZ_APP_LAUNCHER
''; '';
}; });
} }