From 09ade49600f31c6b854410d2c55b043d6efa3275 Mon Sep 17 00:00:00 2001 From: Arpit Chakladar Date: Sun, 2 Aug 2026 01:57:58 +0530 Subject: feat: fixed chromium extension ids, duplicate sent emails, etc - Every home-manager switch had a change to change the ids of the extensions, now we get the same extension id for any build of the given extension - Sending emails from neomutt send duplicate emails, it is now fixed - Auto re-registering in usque-warp connect, as it gets deactivated in about 24 hours - Using a style.mustache.css for the waybar css configs for syntax highlighting --- modules/web/chromium/extensions/lib.nix | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'modules/web/chromium/extensions/lib.nix') diff --git a/modules/web/chromium/extensions/lib.nix b/modules/web/chromium/extensions/lib.nix index 8821b03..d319a5c 100644 --- a/modules/web/chromium/extensions/lib.nix +++ b/modules/web/chromium/extensions/lib.nix @@ -73,6 +73,7 @@ rec { url, hash, isCrx ? false, + extensionKey ? null, # NEW: Accept an optional public key }: pkgs.stdenv.mkDerivation { inherit pname version; @@ -80,6 +81,7 @@ rec { nativeBuildInputs = [ config.file-management.ouch.package + pkgs.jq # NEW: Required for safely editing manifest.json ]; dontUnpack = true; @@ -96,10 +98,7 @@ rec { fi # Extract header length (bytes 8-11, little-endian) - # -An (no address), -j8 (skip 8 bytes), -N4 (read 4 bytes), -tu1 (unsigned decimal 1-byte) bytes=$(od -An -j8 -N4 -tu1 "$src") - - # Read into individual variables and calculate the length read b1 b2 b3 b4 <<< $bytes hlen=$(( b1 + (b2 << 8) + (b3 << 16) + (b4 << 24) )) offset=$(( 12 + hlen )) @@ -118,13 +117,23 @@ rec { shopt -u dotglob fi + # NEW: Inject the public key into manifest.json if provided + ${lib.optionalString (extensionKey != null) '' + if [ -f "$out/manifest.json" ]; then + echo "Injecting extension key into manifest.json to lock the extension ID..." + jq '.key = "${extensionKey}"' "$out/manifest.json" > "$out/manifest.tmp.json" + mv "$out/manifest.tmp.json" "$out/manifest.json" + else + echo "Warning: No manifest.json found in $out to inject the key!" >&2 + fi + ''} + runHook postBuild ''; installPhase = "true"; - }; + }; # --- Package a local directory as an unpacked extension derivation. --- - # --- Package a local directory as an unpacked extension derivation. --- mkLocalExtension = { pname, -- cgit v1.2.3