1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-12-24 02:39:48 +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";
githubId = 9915675;
};
bricked = {
name = "Bricked";
email = "hello@bricked.dev";
github = "brckd";
githubId = 92804487;
};
CarlosLoboxyz = {
name = "Carlos Lobo";
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/borgmatic
./modules/programs/boxxy
./modules/programs/firefox
./modules/programs/firefox/firefox.nix
./modules/programs/foot
./modules/programs/freetube
./modules/programs/fuzzel

View file

@ -1,27 +1,32 @@
modulePath:
{ config, lib, ... }:
{
imports = [ ./setup-firefox-mock-overlay.nix ];
with lib;
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 =
[ "Container id must be smaller than 4294967294 (2^32 - 2)" ];
} // setAttrByPath modulePath {
enable = true;
programs.firefox = {
enable = true;
profiles.my-profile = {
isDefault = true;
id = 1;
profiles.my-profile = {
isDefault = true;
id = 1;
containers = {
"shopping" = {
id = 4294967294;
color = "blue";
icon = "circle";
};
containers = {
"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;
{
imports = [ ./setup-firefox-mock-overlay.nix ];
let
config = lib.mkIf config.test.enableBig {
programs.firefox = {
enable = true;
enableGnomeExtensions = true;
};
moduleName = concatStringsSep "." modulePath;
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 = [''
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
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.
''];
};
});
}

View file

@ -1,35 +1,42 @@
modulePath:
{ config, lib, ... }:
{
imports = [ ./setup-firefox-mock-overlay.nix ];
with lib;
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 = [''
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''];
} // setAttrByPath modulePath {
enable = true;
programs.firefox = {
enable = true;
profiles = {
my-profile = {
isDefault = true;
id = 1;
profiles = {
my-profile = {
isDefault = true;
id = 1;
containers = {
"shopping" = {
id = 9;
color = "blue";
icon = "circle";
};
"dangerous" = {
id = 9;
color = "red";
icon = "circle";
};
containers = {
"shopping" = {
id = 9;
color = "blue";
icon = "circle";
};
"dangerous" = {
id = 9;
color = "red";
icon = "circle";
};
};
};
};
};
});
}

View file

@ -1,23 +1,30 @@
modulePath:
{ config, lib, ... }:
{
imports = [ ./setup-firefox-mock-overlay.nix ];
with lib;
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 = [''
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''];
} // setAttrByPath modulePath {
enable = true;
programs.firefox = {
enable = true;
profiles = {
first = {
isDefault = true;
id = 1;
};
second = { id = 1; };
profiles = {
first = {
isDefault = true;
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, ... }:
{
imports = [ ./setup-firefox-mock-overlay.nix ];
with lib;
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";
programs.firefox = {
enable = true;
policies = { BlockAboutConfig = true; };
package = pkgs.firefox.override {
extraPolicies = { DownloadDirectory = "/foo"; };
};
} // setAttrByPath modulePath {
enable = true;
policies = { BlockAboutConfig = true; };
package = pkgs.${cfg.wrappedPackageName}.override {
extraPolicies = { DownloadDirectory = "/foo"; };
};
}) // {
nmt.script = ''
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"

View file

@ -1,177 +1,184 @@
modulePath:
{ config, lib, pkgs, ... }:
{
imports = [ ./setup-firefox-mock-overlay.nix ];
with lib;
config = lib.mkIf config.test.enableBig {
programs.firefox = {
enable = true;
profiles.basic.isDefault = true;
let
profiles.test = {
id = 1;
settings = {
"general.smoothScroll" = false;
"browser.newtabpage.pinned" = [{
title = "NixOS";
url = "https://nixos.org";
cfg = getAttrFromPath modulePath config;
firefoxMockOverlay = import ./setup-firefox-mock-overlay.nix modulePath;
in {
imports = [ firefoxMockOverlay ];
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 = {
id = 2;
settings = { "general.smoothScroll" = false; };
bookmarks = [
{
toolbar = true;
bookmarks = [{
name = "Home Manager";
url = "https://wiki.nixos.org/wiki/Home_Manager";
profiles.search = {
id = 3;
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}";
}
];
}];
}
{
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 = {
id = 3;
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 =
"/run/current-system/sw/share/icons/hicolor/scalable/apps/nix-snowflake.svg";
icon =
"/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";
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";
};
};
};
profiles.searchWithoutDefault = {
id = 4;
search = {
force = true;
order = [ "Google" "Nix Packages" ];
engines = {
"Nix Packages" = {
urls = [{
template = "https://search.nixos.org/packages";
params = [
{
name = "type";
value = "packages";
}
{
name = "query";
value = "{searchTerms}";
}
];
}];
profiles.searchWithoutDefault = {
id = 4;
search = {
force = true;
order = [ "Google" "Nix Packages" ];
engines = {
"Nix Packages" = {
urls = [{
template = "https://search.nixos.org/packages";
params = [
{
name = "type";
value = "packages";
}
{
name = "query";
value = "{searchTerms}";
}
];
}];
definedAliases = [ "@np" ];
};
};
};
};
profiles.containers = {
id = 5;
containers = {
"shopping" = {
id = 6;
icon = "circle";
color = "yellow";
definedAliases = [ "@np" ];
};
};
};
};
profiles.containers = {
id = 5;
containers = {
"shopping" = {
id = 6;
icon = "circle";
color = "yellow";
};
};
};
} // {
nmt.script = ''
assertFileRegex \
home-path/bin/firefox \
home-path/bin/${cfg.wrappedPackageName} \
MOZ_APP_LAUNCHER
assertDirectoryExists home-files/.mozilla/firefox/basic
assertDirectoryExists home-files/${cfg.configPath}/basic
assertFileContent \
home-files/.mozilla/firefox/test/user.js \
home-files/${cfg.configPath}/test/user.js \
${./profile-settings-expected-user.js}
assertFileContent \
home-files/.mozilla/firefox/containers/containers.json \
home-files/${cfg.configPath}/containers/containers.json \
${./profile-settings-expected-containers.json}
bookmarksUserJs=$(normalizeStorePaths \
home-files/.mozilla/firefox/bookmarks/user.js)
home-files/${cfg.configPath}/bookmarks/user.js)
assertFileContent \
$bookmarksUserJs \
@ -179,7 +186,7 @@
bookmarksFile="$(sed -n \
'/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 \
$bookmarksFile \
@ -197,12 +204,12 @@
}
assertFirefoxSearchContent \
home-files/.mozilla/firefox/search/search.json.mozlz4 \
home-files/${cfg.configPath}/search/search.json.mozlz4 \
${./profile-settings-expected-search.json}
assertFirefoxSearchContent \
home-files/.mozilla/firefox/searchWithoutDefault/search.json.mozlz4 \
home-files/${cfg.configPath}/searchWithoutDefault/search.json.mozlz4 \
${./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 = [
(self: super: {
firefox-unwrapped = pkgs.runCommandLocal "firefox-0" {
meta.description = "I pretend to be Firefox";
passthru.gtk3 = null;
} ''
mkdir -p "$out"/{bin,lib}
touch "$out/bin/firefox"
chmod 755 "$out/bin/firefox"
'';
"${cfg.wrappedPackageName}-unwrapped" =
pkgs.runCommandLocal "${cfg.wrappedPackageName}-0" {
meta.description = "I pretend to be ${cfg.name}";
passthru.gtk3 = null;
} ''
mkdir -p "$out"/{bin,lib}
touch "$out/bin/${cfg.wrappedPackageName}"
chmod 755 "$out/bin/${cfg.wrappedPackageName}"
'';
chrome-gnome-shell =
pkgs.runCommandLocal "dummy-chrome-gnome-shell" { } ''

View file

@ -1,19 +1,24 @@
modulePath:
{ config, lib, pkgs, ... }:
with lib;
{
imports = [ ./setup-firefox-mock-overlay.nix ];
let
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";
programs.firefox.enable = true;
} // setAttrByPath modulePath { enable = true; } // {
nmt.script = ''
assertFileRegex \
home-path/bin/firefox \
home-path/bin/${cfg.wrappedPackageName} \
MOZ_APP_LAUNCHER
'';
};
});
}