about summary refs log tree commit diff
path: root/pkgs/build-support/fetchfirefoxaddon
diff options
context:
space:
mode:
authorLuis Hebendanz <luis.nixos@gmail.com>2020-11-30 16:30:46 +0100
committerJörg Thalheim <joerg@thalheim.io>2020-12-02 09:40:53 +0100
commit397597f731de70130ee3949a22c99c6236c16c06 (patch)
tree280cd77df0501d0553679ea4f6457278e5cdb3f2 /pkgs/build-support/fetchfirefoxaddon
parenteedee46f2fff823147d1b9aaa767397737bdea11 (diff)
Added fetchfirefoxaddon
Diffstat (limited to 'pkgs/build-support/fetchfirefoxaddon')
-rw-r--r--pkgs/build-support/fetchfirefoxaddon/default.nix38
1 files changed, 38 insertions, 0 deletions
diff --git a/pkgs/build-support/fetchfirefoxaddon/default.nix b/pkgs/build-support/fetchfirefoxaddon/default.nix
new file mode 100644
index 0000000000000..b199a46e7934d
--- /dev/null
+++ b/pkgs/build-support/fetchfirefoxaddon/default.nix
@@ -0,0 +1,38 @@
+{stdenv, lib, coreutils, unzip, jq, zip, fetchurl,writeScript,  ...}:
+let
+
+in
+  { name,
+  url,
+  sha256,
+}:
+
+stdenv.mkDerivation rec {
+
+  inherit name;
+  extid = "${sha256}@${name}";
+  passthru = {
+    exitd=extid;
+  };
+
+  builder = writeScript "xpibuilder" ''
+    source $stdenv/setup
+
+    header "firefox addon $name into $out"
+
+    UUID="${extid}"
+    mkdir -p "$out/$UUID"
+    unzip -q ${src} -d "$out/$UUID"
+    NEW_MANIFEST=$(jq '. + {"applications": { "gecko": { "id": "${extid}" }}, "browser_specific_settings":{"gecko":{"id": "${extid}"}}}' "$out/$UUID/manifest.json")
+    echo "$NEW_MANIFEST" > "$out/$UUID/manifest.json"
+    cd "$out/$UUID"
+    zip -r -q -FS "$out/$UUID.xpi" *
+    rm -r "$out/$UUID"
+  '';
+  src = fetchurl {
+    url = url;
+    sha256 = sha256;
+  };
+  nativeBuildInputs = [ coreutils unzip zip jq  ];
+}
+