diff options
author | Artturin <Artturin@artturin.com> | 2021-10-03 03:43:41 +0300 |
---|---|---|
committer | Artturin <Artturin@artturin.com> | 2021-10-03 03:43:41 +0300 |
commit | cd42b9fff8581b36ddd843241d42e214715af851 (patch) | |
tree | bbf88c8adc27f7120344ab42826122d73d2dd038 /pkgs/build-support/fetchfirefoxaddon | |
parent | bc4e52b69745d86e6eecb52b3d0ff9683cbeadf4 (diff) |
fetchfirefoxaddon: Allow overriding the src and add a test for it
Co-authored-by: Thomas Sean Dominic Kelly <thomassdk@pm.me>
Diffstat (limited to 'pkgs/build-support/fetchfirefoxaddon')
-rw-r--r-- | pkgs/build-support/fetchfirefoxaddon/default.nix | 21 | ||||
-rw-r--r-- | pkgs/build-support/fetchfirefoxaddon/tests.nix | 13 |
2 files changed, 24 insertions, 10 deletions
diff --git a/pkgs/build-support/fetchfirefoxaddon/default.nix b/pkgs/build-support/fetchfirefoxaddon/default.nix index 127f32dd61b6b..79014fd23c482 100644 --- a/pkgs/build-support/fetchfirefoxaddon/default.nix +++ b/pkgs/build-support/fetchfirefoxaddon/default.nix @@ -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 ]; } diff --git a/pkgs/build-support/fetchfirefoxaddon/tests.nix b/pkgs/build-support/fetchfirefoxaddon/tests.nix index d125be196aff7..c407d0e74b821 100644 --- a/pkgs/build-support/fetchfirefoxaddon/tests.nix +++ b/pkgs/build-support/fetchfirefoxaddon/tests.nix @@ -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; + }; } |