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