1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2024-12-15 17:25:11 +00:00
nixpkgs/pkgs/build-support/fetchfirefoxaddon/default.nix

42 lines
956 B
Nix
Raw Normal View History

2020-11-30 15:30:46 +00:00
{stdenv, lib, coreutils, unzip, jq, zip, fetchurl,writeScript, ...}:
{
name
2020-11-30 17:49:29 +00:00
, url
, md5 ? ""
, sha1 ? ""
, sha256 ? ""
, sha512 ? ""
, fixedExtid ? null
, hash ? ""
2020-11-30 15:30:46 +00:00
}:
2020-11-30 15:30:46 +00:00
stdenv.mkDerivation rec {
inherit name;
extid = if fixedExtid == null then "nixos@${name}" else fixedExtid;
2020-11-30 15:30:46 +00:00
passthru = {
2020-12-09 19:58:00 +00:00
inherit extid;
2020-11-30 15:30:46 +00:00
};
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;
2020-11-30 15:30:46 +00:00
};
nativeBuildInputs = [ coreutils unzip zip jq ];
}