aboutsummaryrefslogtreecommitdiffstats
path: root/updates/web/chromium/extensions.nix
diff options
context:
space:
mode:
authorArpit Chakladar <arpitchakladar+git@gmail.com>2026-08-19 00:54:32 +0530
committerArpit Chakladar <arpitchakladar+git@gmail.com>2026-08-29 03:50:27 +0530
commit23c07949ab400a49f05405feb5071812e6b81311 (patch)
treedb45bc8534cd5f4ce964b8f320998ebe93a73e13 /updates/web/chromium/extensions.nix
parenta6fa6db17373eefaa2cffbfc4b882b145a733f9f (diff)
downloadhome-manager-config-23c07949ab400a49f05405feb5071812e6b81311.tar.gz
home-manager-config-23c07949ab400a49f05405feb5071812e6b81311.zip
refactor: remove eval-time impurities from chromium extensions
- Remove builtins.fetchurl-based version checking from lib.nix - Move each extension into its own directory with default.nix + metadata.nix - Add extensions/metadata.nix to compile all update metadata into a list - Generate update checks via a standalone shell script in updates/
Diffstat (limited to 'updates/web/chromium/extensions.nix')
-rw-r--r--updates/web/chromium/extensions.nix103
1 files changed, 46 insertions, 57 deletions
diff --git a/updates/web/chromium/extensions.nix b/updates/web/chromium/extensions.nix
index a320113..0d44652 100644
--- a/updates/web/chromium/extensions.nix
+++ b/updates/web/chromium/extensions.nix
@@ -1,68 +1,57 @@
{ pkgs, lib, ... }:
+let
+ extensions = import ../../../modules/web/chromium/extensions/metadata.nix;
+in
{
- # Takes a list of extension attribute sets and generates a bash script to check for updates.
- # Expected attribute set format per extension:
- # {
- # pname = "extension-name";
- # owner = "github-owner";
- # repo = "github-repo";
- # version = "current-pinned-version";
- # updateType = "release" | "tag";
- # tagPrefix = "v"; # (Optional)
- # }
- mkUpdateScript =
- { extensions }:
- pkgs.writeShellApplication {
- name = "check-chromium-extension-updates";
- runtimeInputs = [
- pkgs.curl
- pkgs.jq
- ];
- text = ''
- echo "🔍 Checking for Chromium extension updates..."
- echo "----------------------------------------------"
- echo ""
+ mkUpdateScript = pkgs.writeShellApplication {
+ name = "check-chromium-extension-updates";
+ runtimeInputs = [
+ pkgs.curl
+ pkgs.jq
+ ];
+ text = ''
+ echo "Checking for Chromium extension updates..."
+ echo "----------------------------------------------"
+ echo ""
- ${lib.concatMapStringsSep "\n" (
- ext:
- let
- isTag = (ext.updateType or "release") == "tag";
- apiEndpoint =
- if isTag then
- "https://api.github.com/repos/${ext.owner}/${ext.repo}/tags"
- else
- "https://api.github.com/repos/${ext.owner}/${ext.repo}/releases/latest";
+ ${lib.concatMapStringsSep "\n" (
+ ext:
+ let
+ isTag = (ext.updateType or "release") == "tag";
+ apiEndpoint =
+ if isTag then
+ "https://api.github.com/repos/${ext.owner}/${ext.repo}/tags"
+ else
+ "https://api.github.com/repos/${ext.owner}/${ext.repo}/releases/latest";
- # jq filter: grab the newest tag name from the tags array, or the tag_name from the release object
- jqFilter = if isTag then ".[0].name" else ".tag_name";
- in
- ''
- # Fetch from GitHub API
- HTTP_RESPONSE=$(curl -sL -w "%{http_code}" "https://api.github.com/repos/${ext.owner}/${ext.repo}")
+ # jq filter: grab the newest tag name from the tags array, or the tag_name from the release object
+ jqFilter = if isTag then ".[0].name" else ".tag_name";
+ in
+ ''
+ # Check ${ext.pname}
+ LATEST_RAW=$(curl -sL --fail "${apiEndpoint}" | jq -r '${jqFilter}')
- LATEST_RAW=$(curl -sL --fail "${apiEndpoint}" | jq -r '${jqFilter}')
+ if [ -z "$LATEST_RAW" ] || [ "$LATEST_RAW" == "null" ]; then
+ echo "FAIL [${ext.pname}] Failed to fetch data from GitHub API."
+ else
+ # Strip prefix if one is specified
+ PREFIX="${ext.tagPrefix}"
+ LATEST_STRIPPED="''${LATEST_RAW#$PREFIX}"
- if [ -z "$LATEST_RAW" ] || [ "$LATEST_RAW" == "null" ]; then
- echo "❌ [${ext.pname}] Failed to fetch data from GitHub API."
+ if [ "$LATEST_STRIPPED" != "${ext.version}" ]; then
+ echo "UPDATE [${ext.pname}] ${ext.version} -> $LATEST_STRIPPED"
+ echo " Repo: https://github.com/${ext.owner}/${ext.repo}"
+ echo ""
else
- # Strip prefix if one is specified
- PREFIX="${ext.tagPrefix or ""}"
- LATEST_STRIPPED="''${LATEST_RAW#$PREFIX}"
-
- if [ "$LATEST_STRIPPED" != "${ext.version}" ]; then
- echo "⚠️ [${ext.pname}] Update available: ${ext.version} -> $LATEST_STRIPPED"
- echo " Repo: https://github.com/${ext.owner}/${ext.repo}"
- echo ""
- else
- echo "✅ [${ext.pname}] Up to date (${ext.version})"
- fi
+ echo "OK [${ext.pname}] ${ext.version}"
fi
- ''
- ) extensions}
+ fi
+ ''
+ ) extensions}
- echo "----------------------------------------------"
- echo "Done!"
- '';
- };
+ echo "----------------------------------------------"
+ echo "Done!"
+ '';
+ };
}