2020-12-03 08:41:04 +00:00
|
|
|
{stdenv, lib, coreutils, unzip, jq, zip, fetchurl,writeScript, ...}:
|
2020-12-25 13:55:36 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
name
|
2021-10-08 15:17:17 +00:00
|
|
|
, url ? null
|
2020-12-03 08:41:04 +00:00
|
|
|
, md5 ? ""
|
|
|
|
, sha1 ? ""
|
|
|
|
, sha256 ? ""
|
|
|
|
, sha512 ? ""
|
2020-12-25 13:55:36 +00:00
|
|
|
, fixedExtid ? null
|
2020-12-09 12:39:15 +00:00
|
|
|
, hash ? ""
|
2021-10-08 15:17:17 +00:00
|
|
|
, src ? ""
|
2020-12-03 08:41:04 +00:00
|
|
|
}:
|
2020-12-25 13:55:36 +00:00
|
|
|
|
2021-10-08 15:17:17 +00:00
|
|
|
let
|
2020-12-25 13:55:36 +00:00
|
|
|
extid = if fixedExtid == null then "nixos@${name}" else fixedExtid;
|
2021-10-08 15:17:17 +00:00
|
|
|
source = if url == null then src else fetchurl {
|
|
|
|
url = url;
|
|
|
|
inherit md5 sha1 sha256 sha512 hash;
|
|
|
|
};
|
|
|
|
in
|
|
|
|
stdenv.mkDerivation {
|
|
|
|
inherit name;
|
|
|
|
|
2020-12-03 08:41:04 +00:00
|
|
|
passthru = {
|
2021-02-05 17:12:51 +00:00
|
|
|
inherit extid;
|
2020-12-03 08:41:04 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
builder = writeScript "xpibuilder" ''
|
|
|
|
source $stdenv/setup
|
|
|
|
|
|
|
|
header "firefox addon $name into $out"
|
|
|
|
|
|
|
|
UUID="${extid}"
|
|
|
|
mkdir -p "$out/$UUID"
|
2021-10-08 15:17:17 +00:00
|
|
|
unzip -q ${source} -d "$out/$UUID"
|
2020-12-03 08:41:04 +00:00
|
|
|
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"
|
|
|
|
'';
|
|
|
|
nativeBuildInputs = [ coreutils unzip zip jq ];
|
|
|
|
}
|