about summary refs log tree commit diff stats
path: root/pkgs/by-name/ge/generate_moz_extension/res
diff options
context:
space:
mode:
authorBenedikt Peetz <benedikt.peetz@b-peetz.de>2024-05-23 13:26:22 +0200
committerBenedikt Peetz <benedikt.peetz@b-peetz.de>2024-05-23 13:26:22 +0200
commit204731c0a69136c9cebcb54f1afecf5145e26bbe (patch)
treefc9132e5dc74e4a8e1327cdd411839a90f9410aa /pkgs/by-name/ge/generate_moz_extension/res
parentrefactor(sys): Modularize and move to `modules/system` or `pkgs` (diff)
downloadnixos-config-204731c0a69136c9cebcb54f1afecf5145e26bbe.tar.gz
nixos-config-204731c0a69136c9cebcb54f1afecf5145e26bbe.zip
refactor(pkgs): Categorize into `by-name` shards
This might not be the perfect way to organize a package set --
especially if the set is not nearly the size of nixpkgs -- but it is
_at_ least a way of organization.
Diffstat (limited to 'pkgs/by-name/ge/generate_moz_extension/res')
-rw-r--r--pkgs/by-name/ge/generate_moz_extension/res/generate_extensions.py44
-rw-r--r--pkgs/by-name/ge/generate_moz_extension/res/reference.json30
-rw-r--r--pkgs/by-name/ge/generate_moz_extension/res/test.json30
3 files changed, 104 insertions, 0 deletions
diff --git a/pkgs/by-name/ge/generate_moz_extension/res/generate_extensions.py b/pkgs/by-name/ge/generate_moz_extension/res/generate_extensions.py
new file mode 100644
index 00000000..ee8cc966
--- /dev/null
+++ b/pkgs/by-name/ge/generate_moz_extension/res/generate_extensions.py
@@ -0,0 +1,44 @@
+#!/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))
diff --git a/pkgs/by-name/ge/generate_moz_extension/res/reference.json b/pkgs/by-name/ge/generate_moz_extension/res/reference.json
new file mode 100644
index 00000000..f46ea8ec
--- /dev/null
+++ b/pkgs/by-name/ge/generate_moz_extension/res/reference.json
@@ -0,0 +1,30 @@
+{
+  "darkreader": {
+    "pname": "darkreader",
+    "version": "4.9.62",
+    "addonId": "addon@darkreader.org",
+    "url": "https://addons.mozilla.org/firefox/downloads/file/4053589/darkreader-4.9.62.xpi",
+    "sha256": "sha256:e537a2cee45ed7c26f79ecd3ed362620e3f00d24c158532a58e163a63a3d60cc"
+  },
+  "firenvim": {
+    "pname": "firenvim",
+    "version": "0.2.14",
+    "addonId": "firenvim@lacamb.re",
+    "url": "https://addons.mozilla.org/firefox/downloads/file/4026386/firenvim-0.2.14.xpi",
+    "sha256": "sha256:a8c495a59e30eaabbb3fcd188db9b5e28b40bffefe41a3f0fa22ecc58c80c2b6"
+  },
+  "keepassxc-browser": {
+    "pname": "keepassxc-browser",
+    "version": "1.8.4",
+    "addonId": "keepassxc-browser@keepassxc.org",
+    "url": "https://addons.mozilla.org/firefox/downloads/file/4045866/keepassxc_browser-1.8.4.xpi",
+    "sha256": "sha256:cc39aa058cb8915cfc88424e2e1cebe3ccfc3f95d7bddb2abd0c4905d2b17719"
+  },
+  "simple-tab-groups": {
+    "pname": "simple-tab-groups",
+    "version": "4.7.2.1",
+    "addonId": "simple-tab-groups@drive4ik",
+    "url": "https://addons.mozilla.org/firefox/downloads/file/3873608/simple_tab_groups-4.7.2.1.xpi",
+    "sha256": "sha256:75077589098ca62c00b86cf9554c6120bf8dc04c5f916fe26f84915f5147b2a4"
+  }
+}
diff --git a/pkgs/by-name/ge/generate_moz_extension/res/test.json b/pkgs/by-name/ge/generate_moz_extension/res/test.json
new file mode 100644
index 00000000..daa1d19a
--- /dev/null
+++ b/pkgs/by-name/ge/generate_moz_extension/res/test.json
@@ -0,0 +1,30 @@
+{
+  "darkreader": {
+    "addon_id": "addon@darkreader.org",
+    "pname": "darkreader",
+    "sha256": "sha256:e537a2cee45ed7c26f79ecd3ed362620e3f00d24c158532a58e163a63a3d60cc",
+    "url": "https://addons.mozilla.org/firefox/downloads/file/4053589/darkreader-4.9.62.xpi",
+    "version": "4.9.62"
+  },
+  "firenvim": {
+    "addon_id": "firenvim@lacamb.re",
+    "pname": "firenvim",
+    "sha256": "sha256:a8c495a59e30eaabbb3fcd188db9b5e28b40bffefe41a3f0fa22ecc58c80c2b6",
+    "url": "https://addons.mozilla.org/firefox/downloads/file/4026386/firenvim-0.2.14.xpi",
+    "version": "0.2.14"
+  },
+  "keepassxc-browser": {
+    "addon_id": "keepassxc-browser@keepassxc.org",
+    "pname": "keepassxc-browser",
+    "sha256": "sha256:cc39aa058cb8915cfc88424e2e1cebe3ccfc3f95d7bddb2abd0c4905d2b17719",
+    "url": "https://addons.mozilla.org/firefox/downloads/file/4045866/keepassxc_browser-1.8.4.xpi",
+    "version": "1.8.4"
+  },
+  "simple-tab-groups": {
+    "addon_id": "simple-tab-groups@drive4ik",
+    "pname": "simple-tab-groups",
+    "sha256": "sha256:75077589098ca62c00b86cf9554c6120bf8dc04c5f916fe26f84915f5147b2a4",
+    "url": "https://addons.mozilla.org/firefox/downloads/file/3873608/simple_tab_groups-4.7.2.1.xpi",
+    "version": "4.7.2.1"
+  }
+}