librewolf: install firefox extensions globally

Reduces complexity since we no longer have to manually update each
package from a non-firefox source.

Requires internet connectivity at runtime but should ensure that the
extensions are always up to date.
This commit is contained in:
Donovan Glover 2024-12-16 18:14:28 -05:00
parent 98283539bb
commit 4f1cde5571
No known key found for this signature in database
GPG Key ID: EA7408A77AE1BE65
6 changed files with 32 additions and 156 deletions

View File

@ -93,11 +93,7 @@ in
profiles = {
default = {
extensions = with nix-config.packages.${pkgs.system}; [
ublock-origin
yomitan
redlib
new-tab-identity
showdex
];
inherit settings search;

32
modules/librewolf.nix Normal file
View File

@ -0,0 +1,32 @@
{ pkgs, ... }:
{
programs.firefox = {
enable = true;
package = pkgs.librewolf;
policies = {
ExtensionSettings = {
"showdex@tize.io" = {
install_url = "https://addons.mozilla.org/firefox/downloads/latest/showdex/latest.xpi";
installation_mode = "force_installed";
};
"{6b733b82-9261-47ee-a595-2dda294a4d08}" = {
install_url = "https://addons.mozilla.org/firefox/downloads/latest/yomitan/latest.xpi";
installation_mode = "force_installed";
};
"{5003e502-f361-4bf6-b09e-41a844d36d33}" = {
install_url = "https://addons.mozilla.org/firefox/downloads/latest/redlib/latest.xpi";
installation_mode = "force_installed";
};
"uBlock0@raymondhill.net" = {
install_url = "https://addons.mozilla.org/firefox/downloads/latest/ublock-origin/latest.xpi";
installation_mode = "force_installed";
};
};
};
};
}

View File

@ -1,33 +0,0 @@
{
lib,
stdenvNoCC,
fetchurl,
}:
stdenvNoCC.mkDerivation (finalAttrs: {
pname = "redlib";
version = "3.2";
src = fetchurl {
url = "https://addons.mozilla.org/firefox/downloads/file/4330244/redlib-${finalAttrs.version}.xpi";
hash = "sha256-j6A/CQ56hKOLgaDcmJBVE9lThn8js4xDkj88wqIzBE8=";
};
dontUnpack = true;
installPhase = ''
runHook preInstall
install -Dm644 "$src" "$out/share/mozilla/extensions/{ec8030f7-c20a-464f-9b0e-13a3a9e97384}/{5003e502-f361-4bf6-b09e-41a844d36d33}.xpi"
runHook postInstall
'';
meta = {
homepage = "https://addons.mozilla.org/en-US/firefox/addon/redlib/";
description = "Redirect to Redlib with Farside";
license = lib.licenses.mit;
maintainers = with lib.maintainers; [ donovanglover ];
platforms = lib.platforms.all;
};
})

View File

@ -1,48 +0,0 @@
{
lib,
stdenvNoCC,
fetchurl,
}:
let
build = "b1923BC50731";
in
stdenvNoCC.mkDerivation (finalAttrs: {
pname = "showdex";
version = "1.2.5";
src = fetchurl {
url = "https://github.com/doshidak/showdex/releases/download/v${finalAttrs.version}/showdex-v${finalAttrs.version}-${build}.firefox.xpi";
hash = "sha256-wn0pF8ar5Ldfc/kNMznzg9NAz+5ckZB7SCEUObj0BPw=";
};
dontUnpack = true;
installPhase = ''
runHook preInstall
install -Dm644 "$src" "$out/share/mozilla/extensions/{ec8030f7-c20a-464f-9b0e-13a3a9e97384}/showdex@tize.io.xpi"
runHook postInstall
'';
passthru.updateScript = # fish
''
set URL $(curl -s https://api.github.com/repos/doshidak/showdex/releases/latest | jq -r ".assets[] | select(.content_type == \"application/x-xpinstall\") | .browser_download_url")
and set VERSION $(echo "$URL" | grep -Eo '[0-9\.]+-' | sd "-" "")
and set BUILD $(echo "$URL" | grep -Eo 'b[A-Z0-9]+')
and set HASH $(nix hash convert --to sri sha256:$(nix-prefetch-url "$URL"))
and sd -n 1 'version = "[^"]*"' "version = \"$VERSION\"" ./packages/showdex.nix
and sd -n 1 'build = "[^"]*"' "build = \"$BUILD\"" ./packages/showdex.nix
and sd -n 1 'hash = "[^"]*"' "hash = \"$HASH\"" ./packages/showdex.nix
'';
meta = {
homepage = "https://github.com/doshidak/showdex";
description = "Pokémon Showdown extension that harnesses the power of parabolic calculus to strategically extract your opponents' Elo";
license = lib.licenses.agpl3Only;
maintainers = with lib.maintainers; [ donovanglover ];
platforms = lib.platforms.all;
};
})

View File

@ -1,33 +0,0 @@
{
lib,
stdenvNoCC,
fetchurl,
}:
stdenvNoCC.mkDerivation (finalAttrs: {
pname = "ublock-origin";
version = "1.61.0";
src = fetchurl {
url = "https://github.com/gorhill/uBlock/releases/download/${finalAttrs.version}/uBlock0_${finalAttrs.version}.firefox.signed.xpi";
hash = "sha256-5v1Vt5mlaMZsEIkqjyJCjmdz/hbXRmzp3uKVLyJLID0=";
};
dontUnpack = true;
installPhase = ''
runHook preInstall
install -Dm644 "$src" "$out/share/mozilla/extensions/{ec8030f7-c20a-464f-9b0e-13a3a9e97384}/uBlock0@raymondhill.net.xpi"
runHook postInstall
'';
meta = {
homepage = "https://addons.mozilla.org/en-US/firefox/addon/ublock-origin/";
description = "Efficient wide-spectrum content blocker";
license = lib.licenses.gpl3Plus;
maintainers = with lib.maintainers; [ donovanglover ];
platforms = lib.platforms.all;
};
})

View File

@ -1,38 +0,0 @@
{
lib,
stdenvNoCC,
fetchurl,
gitUpdater,
}:
stdenvNoCC.mkDerivation (finalAttrs: {
pname = "yomitan";
version = "24.10.7.0";
src = fetchurl {
url = "https://github.com/yomidevs/yomitan/releases/download/${finalAttrs.version}/yomitan-firefox.zip";
hash = "sha256-d2PmqLm3uYVc2S5hUFe9zOnbih7N7f2mQKc5O8qqPs8=";
};
dontUnpack = true;
installPhase = ''
runHook preInstall
install -Dm644 "$src" "$out/share/mozilla/extensions/{ec8030f7-c20a-464f-9b0e-13a3a9e97384}/{6b733b82-9261-47ee-a595-2dda294a4d08}.xpi"
runHook postInstall
'';
passthru.updateScript = gitUpdater {
url = "https://github.com/yomidevs/yomitan";
};
meta = {
homepage = "https://addons.mozilla.org/en-US/firefox/addon/yomitan/";
description = "Japanese dictionary with Anki integration";
license = lib.licenses.gpl3Plus;
maintainers = with lib.maintainers; [ donovanglover ];
platforms = lib.platforms.all;
};
})