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,13 +1,19 @@
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 {
programs.firefox = {
enable = true; enable = true;
profiles.my-profile = { profiles.my-profile = {
@ -22,6 +28,5 @@
}; };
}; };
}; };
}; });
};
} }

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 = {
firefoxMockOverlay = import ./setup-firefox-mock-overlay.nix modulePath;
in {
imports = [ firefoxMockOverlay ];
config = mkIf config.test.enableBig (setAttrByPath modulePath {
enable = true; enable = true;
enableGnomeExtensions = 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,14 +1,22 @@
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 {
programs.firefox = {
enable = true; enable = true;
profiles = { profiles = {
@ -30,6 +38,5 @@
}; };
}; };
}; };
}; });
};
} }

View file

@ -1,14 +1,22 @@
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 {
programs.firefox = {
enable = true; enable = true;
profiles = { profiles = {
@ -18,6 +26,5 @@
}; };
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.firefox.override { package = pkgs.${cfg.wrappedPackageName}.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,10 +1,18 @@
modulePath:
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
{ with lib;
imports = [ ./setup-firefox-mock-overlay.nix ];
config = lib.mkIf config.test.enableBig { let
programs.firefox = {
cfg = getAttrFromPath modulePath config;
firefoxMockOverlay = import ./setup-firefox-mock-overlay.nix modulePath;
in {
imports = [ firefoxMockOverlay ];
config = mkIf config.test.enableBig (setAttrByPath modulePath {
enable = true; enable = true;
profiles.basic.isDefault = true; profiles.basic.isDefault = true;
@ -34,8 +42,7 @@
name = "wikipedia"; name = "wikipedia";
tags = [ "wiki" ]; tags = [ "wiki" ];
keyword = "wiki"; keyword = "wiki";
url = url = "https://en.wikipedia.org/wiki/Special:Search?search=%s&go=Go";
"https://en.wikipedia.org/wiki/Special:Search?search=%s&go=Go";
} }
{ {
name = "kernel.org"; name = "kernel.org";
@ -153,25 +160,25 @@
}; };
}; };
}; };
}; } // {
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,15 +1,23 @@
{ 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" {
meta.description = "I pretend to be ${cfg.name}";
passthru.gtk3 = null; passthru.gtk3 = null;
} '' } ''
mkdir -p "$out"/{bin,lib} mkdir -p "$out"/{bin,lib}
touch "$out/bin/firefox" touch "$out/bin/${cfg.wrappedPackageName}"
chmod 755 "$out/bin/firefox" chmod 755 "$out/bin/${cfg.wrappedPackageName}"
''; '';
chrome-gnome-shell = 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
''; '';
}; });
} }