aboutsummaryrefslogtreecommitdiffstats
path: root/updates/web/chromium
diff options
context:
space:
mode:
authorArpit Chakladar <arpitchakladar@gmail.com>2026-09-09 17:59:41 +0530
committerArpit Chakladar <arpitchakladar@gmail.com>2026-09-09 17:59:41 +0530
commit4a9bd882f7fdf00b26427ea70572dc38e7cab8bf (patch)
tree503734d082f6ec389b5ebdf359e0554617e7109d /updates/web/chromium
parent1f82802bf50bb5c935efea47aef0418fc602492e (diff)
parent022e4a37219c2ad8f0aa6cbb8281b060b7e98bf0 (diff)
downloadhome-manager-config-4a9bd882f7fdf00b26427ea70572dc38e7cab8bf.tar.gz
home-manager-config-4a9bd882f7fdf00b26427ea70572dc38e7cab8bf.zip
Merge branch 'setting-up-bash'
Diffstat (limited to 'updates/web/chromium')
-rw-r--r--updates/web/chromium/check-chromium-extension-updates.lua56
-rw-r--r--updates/web/chromium/extensions.nix81
2 files changed, 92 insertions, 45 deletions
diff --git a/updates/web/chromium/check-chromium-extension-updates.lua b/updates/web/chromium/check-chromium-extension-updates.lua
new file mode 100644
index 0000000..815e8a4
--- /dev/null
+++ b/updates/web/chromium/check-chromium-extension-updates.lua
@@ -0,0 +1,56 @@
+#!/usr/bin/env luajit
+-- Checks for updated Chromium extensions against their GitHub releases/tags.
+
+local extensions = {
+ -- NOTE: replaced by the derivation build step, with the
+ -- detailed list of all extensions that we need to check
+ --@@EXTENSIONS@@--
+}
+
+local function printf(fmt, ...)
+ io.write(string.format(fmt, ...))
+end
+
+print("Checking for Chromium extension updates...")
+print("----------------------------------------------")
+print("")
+
+for _, ext in ipairs(extensions) do
+ local isTag = ext.updateType == "tag"
+ local endpoint
+ local jqFilter
+ if isTag then
+ endpoint = string.format("https://api.github.com/repos/%s/%s/tags", ext.owner, ext.repo)
+ jqFilter = ".[0].name"
+ else
+ endpoint = string.format("https://api.github.com/repos/%s/%s/releases/latest", ext.owner, ext.repo)
+ jqFilter = ".tag_name"
+ end
+
+ local proc = io.popen(string.format("curl -sL --fail %q | jq -r %q", endpoint, jqFilter))
+ local latestRaw = (proc and proc:read("*a") or ""):gsub("%s+$", "")
+ if proc then
+ proc:close()
+ end
+
+ if latestRaw == "" or latestRaw == "null" then
+ printf("FAIL [%s] Failed to fetch data from GitHub API.\n", ext.pname)
+ else
+ local prefix = ext.tagPrefix
+ local latest = latestRaw
+ if prefix ~= "" and latestRaw:sub(1, #prefix) == prefix then
+ latest = latestRaw:sub(#prefix + 1)
+ end
+
+ if latest ~= ext.version then
+ printf("UPDATE [%s] %s -> %s\n", ext.pname, ext.version, latest)
+ printf(" Repo: https://github.com/%s/%s\n", ext.owner, ext.repo)
+ print("")
+ else
+ printf("OK [%s] %s\n", ext.pname, ext.version)
+ end
+ end
+end
+
+print("----------------------------------------------")
+print("Done!")
diff --git a/updates/web/chromium/extensions.nix b/updates/web/chromium/extensions.nix
index d9de16d..ab6e818 100644
--- a/updates/web/chromium/extensions.nix
+++ b/updates/web/chromium/extensions.nix
@@ -1,54 +1,45 @@
-{ pkgs, lib, ... }:
+{
+ pkgs,
+ lib,
+ ...
+}:
let
extensions = import ../../../modules/web/chromium/extensions/metadata.nix;
+
+ luaExtensionList = lib.concatMapStringsSep "\n" (ext: ''
+ { pname = "${ext.pname}", owner = "${ext.owner}", repo = "${ext.repo}", version = "${ext.version}", updateType = "${ext.updateType or "release"}", tagPrefix = "${ext.tagPrefix}" },
+ '') extensions;
+
+ luaScript = pkgs.writeText "check-chromium-extension-updates.lua" (
+ builtins.replaceStrings [ "--@@EXTENSIONS@@--" ] [ luaExtensionList ] (
+ builtins.readFile ./check-chromium-extension-updates.lua
+ )
+ );
in
{
- mkUpdateScript = pkgs.writeShellApplication {
- name = "check-chromium-extension-updates";
- runtimeInputs = [
- pkgs.curl
- pkgs.jq
+ mkUpdateScript = pkgs.stdenv.mkDerivation {
+ pname = "check-chromium-extension-updates";
+ version = "0.1.0";
+ dontUnpack = true;
+ nativeBuildInputs = [
+ pkgs.luajit
+ pkgs.makeWrapper
];
- 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";
- jqFilter = if isTag then ".[0].name" else ".tag_name";
- in
- ''
- # Check ${ext.pname}
- 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
- PREFIX="${ext.tagPrefix}"
- LATEST_STRIPPED="''${LATEST_RAW#"$PREFIX"}"
-
- 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
- echo "OK [${ext.pname}] ${ext.version}"
- fi
- fi
- ''
- ) extensions}
-
- echo "----------------------------------------------"
- echo "Done!"
+ installPhase = ''
+ mkdir -p $out/bin
+ install -m755 ${luaScript} $out/bin/check-chromium-extension-updates
+ patchShebangs $out/bin/check-chromium-extension-updates
+ wrapProgram $out/bin/check-chromium-extension-updates \
+ --prefix PATH : "${
+ lib.makeBinPath [
+ pkgs.curl
+ pkgs.jq
+ ]
+ }"
'';
+ meta = {
+ mainProgram = "check-chromium-extension-updates";
+ };
};
}