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 name
, url , url ? null
, md5 ? "" , md5 ? ""
, sha1 ? "" , sha1 ? ""
, sha256 ? "" , sha256 ? ""
, sha512 ? "" , sha512 ? ""
, fixedExtid ? null , fixedExtid ? null
, hash ? "" , hash ? ""
, src ? ""
}: }:
stdenv.mkDerivation rec { let
inherit name;
extid = if fixedExtid == null then "nixos@${name}" else fixedExtid; 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 = { passthru = {
inherit extid; inherit extid;
}; };
@ -26,16 +33,12 @@ stdenv.mkDerivation rec {
UUID="${extid}" UUID="${extid}"
mkdir -p "$out/$UUID" 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") NEW_MANIFEST=$(jq '. + {"applications": { "gecko": { "id": "${extid}" }}, "browser_specific_settings":{"gecko":{"id": "${extid}"}}}' "$out/$UUID/manifest.json")
echo "$NEW_MANIFEST" > "$out/$UUID/manifest.json" echo "$NEW_MANIFEST" > "$out/$UUID/manifest.json"
cd "$out/$UUID" cd "$out/$UUID"
zip -r -q -FS "$out/$UUID.xpi" * zip -r -q -FS "$out/$UUID.xpi" *
rm -r "$out/$UUID" rm -r "$out/$UUID"
''; '';
src = fetchurl {
url = url;
inherit md5 sha1 sha256 sha512 hash;
};
nativeBuildInputs = [ coreutils unzip zip jq ]; nativeBuildInputs = [ coreutils unzip zip jq ];
} }

View file

@ -1,4 +1,4 @@
{ invalidateFetcherByDrvHash, fetchFirefoxAddon, ... }: { invalidateFetcherByDrvHash, fetchFirefoxAddon, fetchurl, ... }:
{ {
simple = invalidateFetcherByDrvHash fetchFirefoxAddon { simple = invalidateFetcherByDrvHash fetchFirefoxAddon {
@ -7,4 +7,15 @@
url = "https://addons.mozilla.org/firefox/downloads/file/3059971/image_search_options-3.0.12-fx.xpi"; url = "https://addons.mozilla.org/firefox/downloads/file/3059971/image_search_options-3.0.12-fx.xpi";
sha256 = "sha256-H73YWX/DKxvhEwKpWOo7orAQ7c/rQywpljeyxYxv0Gg="; 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;
};
} }