diff options
Diffstat (limited to 'pkgs/firefoxAddonUpdateScript')
| -rw-r--r-- | pkgs/firefoxAddonUpdateScript/package.nix | 32 | ||||
| -rw-r--r-- | pkgs/firefoxAddonUpdateScript/script.sh | 29 |
2 files changed, 61 insertions, 0 deletions
diff --git a/pkgs/firefoxAddonUpdateScript/package.nix b/pkgs/firefoxAddonUpdateScript/package.nix new file mode 100644 index 0000000..9590caa --- /dev/null +++ b/pkgs/firefoxAddonUpdateScript/package.nix @@ -0,0 +1,32 @@ +{ + lib, + common-updater-scripts, + curl, + jq, + writeShellApplication, +}: + +let + script = writeShellApplication { + name = "firefox-addon-update-script"; + + runtimeInputs = [ + common-updater-scripts + curl + jq + ]; + + text = lib.fileContents ./script.sh; + }; +in + +{ + addonRef, + attrPath, +}: + +[ + (lib.getExe script) + attrPath + addonRef +] diff --git a/pkgs/firefoxAddonUpdateScript/script.sh b/pkgs/firefoxAddonUpdateScript/script.sh new file mode 100644 index 0000000..1d13cac --- /dev/null +++ b/pkgs/firefoxAddonUpdateScript/script.sh @@ -0,0 +1,29 @@ +# shellcheck shell=bash + +readonly AMO_API="https://addons.mozilla.org/api/v5" +readonly ADDON_ENDPOINT="/addons/addon" + +attribute="${1:-}" +addon_ref="${2:-}" + +usage() { + echo " +usage: $0 <attribute> <addon_ref> +" +} + +bail() { + usage + exit 1 +} + +if [[ -z $attribute ]] || [[ -z $addon_ref ]]; then + bail +fi + +data="$(curl -sSL "$AMO_API/$ADDON_ENDPOINT/$addon_ref")" + +url="$(jq -r '.current_version.file.url' <<<"$data")" +version="$(jq -r '.current_version.version' <<<"$data")" + +update-source-version "$attribute" "$version" "" "$url" |
