about summary refs log tree commit diff stats
path: root/sys/nixpkgs/pkgs/generate_moz_extension/res/generate_extensions.py
diff options
context:
space:
mode:
authorSoispha <soispha@vhack.eu>2024-03-23 14:59:36 +0100
committerSoispha <soispha@vhack.eu>2024-03-23 14:59:36 +0100
commit8816ccb0b24c40086d9caebccb97ea8d73102630 (patch)
treeee3e08e1ad1244eb1468b238fa2d69cd8a5d643a /sys/nixpkgs/pkgs/generate_moz_extension/res/generate_extensions.py
parentfix(pkgs/scripts/update-sys): Add new `systemd-run` dependency (diff)
downloadnixos-config-8816ccb0b24c40086d9caebccb97ea8d73102630.tar.gz
nixos-config-8816ccb0b24c40086d9caebccb97ea8d73102630.zip
feat(pkgs/generate_moz_extensions): Vendor it
This project was hosted as a separate git repository. It is now
vendored, like the other projects directly associated with the
configuration.
Diffstat (limited to 'sys/nixpkgs/pkgs/generate_moz_extension/res/generate_extensions.py')
-rw-r--r--sys/nixpkgs/pkgs/generate_moz_extension/res/generate_extensions.py40
1 files changed, 40 insertions, 0 deletions
diff --git a/sys/nixpkgs/pkgs/generate_moz_extension/res/generate_extensions.py b/sys/nixpkgs/pkgs/generate_moz_extension/res/generate_extensions.py
new file mode 100644
index 00000000..459be0d0
--- /dev/null
+++ b/sys/nixpkgs/pkgs/generate_moz_extension/res/generate_extensions.py
@@ -0,0 +1,40 @@
+#!/usr/bin/env python
+# source: https://github.com/etu/nixconfig/blob/ba47d577c8bfb4a1c06927c34ece34118f4a0460/modules/graphical/firefox/generate.py
+
+from concurrent.futures import ThreadPoolExecutor
+import json
+import requests
+
+EXTENSIONS = sorted([
+    "darkreader",
+    "firenvim",
+    "keepassxc-browser",
+    "simple-tab-groups",
+])
+
+def index_ext(ext: str):
+    # print(f"Indexing {ext}...")
+
+    resp = requests.get(f"https://addons.mozilla.org/api/v5/addons/addon/{ext}/").json()
+    rel = resp["current_version"]
+
+    if not rel["file"]["hash"].startswith("sha256:"):
+        raise ValueError("Unhandled hash type")
+
+    return {
+        "pname": ext,
+        "version": rel["version"],
+        "addonId": resp["guid"],
+        "url": rel["file"]["url"],
+        "sha256": rel["file"]["hash"],
+    }
+
+if __name__ == "__main__":
+    # outfile = os.path.dirname(os.path.realpath(__file__)) + "/extensions.json"
+
+    with ThreadPoolExecutor() as e:
+        extensions = {ext: e.submit(index_ext, ext) for ext in EXTENSIONS}
+        extensions = {k: v.result() for k, v in extensions.items()}
+
+    #with open(outfile, "w") as f:
+    print(json.dumps(extensions, indent=2))