Merge pull request #140337 from Artturin/overidesrcfetchff

This commit is contained in:
Artturi 2021-10-07 18:20:05 +03:00 committed by GitHub
commit 46c22f8932
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 10 deletions

View File

@ -2,19 +2,26 @@
{
name
, url
, url ? null
, md5 ? ""
, sha1 ? ""
, sha256 ? ""
, sha512 ? ""
, fixedExtid ? null
, hash ? ""
, src ? ""
}:
stdenv.mkDerivation rec {
inherit name;
let
extid = if fixedExtid == null then "nixos@${name}" else fixedExtid;
source = if url == null then src else fetchurl {
url = url;
inherit md5 sha1 sha256 sha512 hash;
};
in
stdenv.mkDerivation {
inherit name;
passthru = {
inherit extid;
};
@ -26,16 +33,12 @@ stdenv.mkDerivation rec {
UUID="${extid}"
mkdir -p "$out/$UUID"
unzip -q ${src} -d "$out/$UUID"
unzip -q ${source} -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 ];
}

View File

@ -1,4 +1,4 @@
{ invalidateFetcherByDrvHash, fetchFirefoxAddon, ... }:
{ invalidateFetcherByDrvHash, fetchFirefoxAddon, fetchurl, ... }:
{
simple = invalidateFetcherByDrvHash fetchFirefoxAddon {
@ -7,4 +7,15 @@
url = "https://addons.mozilla.org/firefox/downloads/file/3059971/image_search_options-3.0.12-fx.xpi";
sha256 = "sha256-H73YWX/DKxvhEwKpWOo7orAQ7c/rQywpljeyxYxv0Gg=";
};
overidden-source =
let
image-search-options = fetchurl {
url = "https://addons.mozilla.org/firefox/downloads/file/3059971/image_search_options-3.0.12-fx.xpi";
sha256 = "sha256-H73YWX/DKxvhEwKpWOo7orAQ7c/rQywpljeyxYxv0Gg=";
};
in
invalidateFetcherByDrvHash fetchFirefoxAddon {
name = "image-search-options";
src = image-search-options;
};
}