mirror of
https://github.com/nix-community/home-manager
synced 2024-11-26 21:19: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:
parent
587fcca66e
commit
792757f643
14 changed files with 1356 additions and 1203 deletions
|
@ -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
1017
modules/programs/firefox/mkFirefoxModule.nix
Normal file
1017
modules/programs/firefox/mkFirefoxModule.nix
Normal file
File diff suppressed because it is too large
Load diff
|
@ -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
|
||||
|
|
|
@ -1,13 +1,19 @@
|
|||
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)" ];
|
||||
|
||||
programs.firefox = {
|
||||
} // setAttrByPath modulePath {
|
||||
enable = true;
|
||||
|
||||
profiles.my-profile = {
|
||||
|
@ -22,6 +28,5 @@
|
|||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
});
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
|
@ -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 = {
|
||||
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.
|
||||
''];
|
||||
};
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,14 +1,22 @@
|
|||
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''];
|
||||
|
||||
programs.firefox = {
|
||||
} // setAttrByPath modulePath {
|
||||
enable = true;
|
||||
|
||||
profiles = {
|
||||
|
@ -30,6 +38,5 @@
|
|||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,14 +1,22 @@
|
|||
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''];
|
||||
|
||||
programs.firefox = {
|
||||
} // setAttrByPath modulePath {
|
||||
enable = true;
|
||||
|
||||
profiles = {
|
||||
|
@ -18,6 +26,5 @@
|
|||
};
|
||||
second = { id = 1; };
|
||||
};
|
||||
};
|
||||
};
|
||||
});
|
||||
}
|
||||
|
|
11
tests/modules/programs/firefox/firefox.nix
Normal file
11
tests/modules/programs/firefox/firefox.nix
Normal 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;
|
||||
}
|
|
@ -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 = {
|
||||
} // setAttrByPath modulePath {
|
||||
enable = true;
|
||||
policies = { BlockAboutConfig = true; };
|
||||
package = pkgs.firefox.override {
|
||||
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"
|
||||
|
||||
|
|
|
@ -1,10 +1,18 @@
|
|||
modulePath:
|
||||
{ config, lib, pkgs, ... }:
|
||||
|
||||
{
|
||||
imports = [ ./setup-firefox-mock-overlay.nix ];
|
||||
with lib;
|
||||
|
||||
config = lib.mkIf config.test.enableBig {
|
||||
programs.firefox = {
|
||||
let
|
||||
|
||||
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;
|
||||
|
||||
|
@ -34,8 +42,7 @@
|
|||
name = "wikipedia";
|
||||
tags = [ "wiki" ];
|
||||
keyword = "wiki";
|
||||
url =
|
||||
"https://en.wikipedia.org/wiki/Special:Search?search=%s&go=Go";
|
||||
url = "https://en.wikipedia.org/wiki/Special:Search?search=%s&go=Go";
|
||||
}
|
||||
{
|
||||
name = "kernel.org";
|
||||
|
@ -153,25 +160,25 @@
|
|||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
} // {
|
||||
|
||||
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}
|
||||
'';
|
||||
};
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,15 +1,23 @@
|
|||
{ 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";
|
||||
"${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/firefox"
|
||||
chmod 755 "$out/bin/firefox"
|
||||
touch "$out/bin/${cfg.wrappedPackageName}"
|
||||
chmod 755 "$out/bin/${cfg.wrappedPackageName}"
|
||||
'';
|
||||
|
||||
chrome-gnome-shell =
|
||||
|
|
|
@ -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
|
||||
'';
|
||||
};
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue