nixpkgs/pkgs/build-support/fetchfirefoxaddon/default.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

58 lines
1.0 KiB
Nix
Raw Permalink Normal View History

{ stdenv
, fetchurl
, jq
2023-06-09 23:45:50 +00:00
, strip-nondeterminism
, unzip
, writeScript
, zip
}:
{ name
, url ? null
2020-11-30 17:49:29 +00:00
, sha1 ? ""
, sha256 ? ""
, sha512 ? ""
, fixedExtid ? null
, hash ? ""
, src ? ""
2020-11-30 15:30:46 +00:00
}:
let
extid = if fixedExtid == null then "nixos@${name}" else fixedExtid;
source = if url == null then src else
fetchurl {
url = url;
inherit sha1 sha256 sha512 hash;
};
in
stdenv.mkDerivation {
inherit name;
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
echo "firefox addon $name into $out"
2020-11-30 15:30:46 +00:00
UUID="${extid}"
mkdir -p "$out/$UUID"
unzip -q ${source} -d "$out/$UUID"
2020-11-30 15:30:46 +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" *
2023-06-09 23:45:50 +00:00
strip-nondeterminism "$out/$UUID.xpi"
2020-11-30 15:30:46 +00:00
rm -r "$out/$UUID"
'';
nativeBuildInputs = [
jq
2023-06-09 23:45:50 +00:00
strip-nondeterminism
unzip
zip
];
2020-11-30 15:30:46 +00:00
}