fetchzip: extraPostFetch -> postFetch && tests

This commit is contained in:
Artturin 2022-05-17 21:49:33 +03:00
parent 7283d3942f
commit 5a6a31e54d
4 changed files with 37 additions and 2 deletions

View File

@ -12,6 +12,7 @@
, url ? ""
, urls ? []
, extraPostFetch ? ""
, postFetch ? ""
, name ? "source"
, nativeBuildInputs ? [ ]
, # Allows to set the extension for the intermediate downloaded
@ -20,6 +21,8 @@
extension ? null
, ... } @ args:
lib.warnIf (extraPostFetch != "") "use 'postFetch' instead of 'extraPostFetch' with 'fetchzip' and 'fetchFromGitHub'."
(fetchurl (let
tmpFilename =
if extension != null
@ -60,11 +63,14 @@ in {
mv "$unpackDir" "$out"
'')
+ ''
${postFetch}
'' + ''
${extraPostFetch}
''
# Remove non-owner write permissions
# Fixes https://github.com/NixOS/nixpkgs/issues/38649
+ ''
chmod 755 "$out"
'';
} // removeAttrs args [ "stripRoot" "extraPostFetch" "extension" "nativeBuildInputs" ]))
} // removeAttrs args [ "stripRoot" "extraPostFetch" "postFetch" "extension" "nativeBuildInputs" ]))

View File

@ -0,0 +1,25 @@
{ testers, fetchzip, ... }:
let
zipUrl = "https://gist.github.com/glandium/01d54cefdb70561b5f6675e08f2990f2/archive/2f430f0c136a69b0886281d0c76708997d8878af.zip";
in
{
simple = testers.invalidateFetcherByDrvHash fetchzip {
inherit zipUrl;
sha256 = "sha256-0ecwgL8qUavSj1+WkaxpmRBmu7cvj53V5eXQV71fddU=";
};
postFetch = testers.invalidateFetcherByDrvHash fetchzip {
inherit zipUrl;
sha256 = "sha256-7sAOzKa+9vYx5XyndHxeY2ffWAjOsgCkXC9anK6cuV0=";
postFetch = ''touch $out/filee'';
};
#extraPostFetch = testers.invalidateFetcherByDrvHash fetchzip {
# inherit url;
# sha256 = "sha256-UC8oJqojqpjqa72UpT0QTME+UwQhVVk5/d9mgRPDR20=";
# extraPostFetch = ''
# touch $out/afile
# '';
#};
}

View File

@ -28,6 +28,7 @@ with pkgs;
cc-multilib-clang = callPackage ./cc-wrapper/multilib.nix { stdenv = clangMultiStdenv; };
fetchpatch = callPackages ../build-support/fetchpatch/tests.nix { };
fetchzip = callPackages ../build-support/fetchzip/tests.nix { };
fetchgit = callPackages ../build-support/fetchgit/tests.nix { };
fetchFirefoxAddon = callPackages ../build-support/fetchfirefoxaddon/tests.nix { };

View File

@ -723,7 +723,10 @@ with pkgs;
inherit curl stdenv;
};
fetchzip = callPackage ../build-support/fetchzip { };
fetchzip = callPackage ../build-support/fetchzip { }
// {
tests = pkgs.tests.fetchzip;
};
fetchCrate = callPackage ../build-support/rust/fetchcrate.nix { };