depot/third_party/nixpkgs/pkgs/build-support/fetchfirefoxaddon/default.nix
Default email b6d97fd731 Project import generated by Copybara.
GitOrigin-RevId: be0b453d7c7eee2090962c9a83749b024ff9acf5
2020-12-25 14:55:36 +01:00

41 lines
954 B
Nix

{stdenv, lib, coreutils, unzip, jq, zip, fetchurl,writeScript, ...}:
{
name
, url
, md5 ? ""
, sha1 ? ""
, sha256 ? ""
, sha512 ? ""
, fixedExtid ? null
, hash ? ""
}:
stdenv.mkDerivation rec {
inherit name;
extid = if fixedExtid == null then "nixos@${name}" else fixedExtid;
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;
inherit md5 sha1 sha256 sha512 hash;
};
nativeBuildInputs = [ coreutils unzip zip jq ];
}