fetchzip: extraPostFetch -> postFetch && tests

main
Artturin 2 years ago
parent 7283d3942f
commit 5a6a31e54d
  1. 8
      pkgs/build-support/fetchzip/default.nix
  2. 25
      pkgs/build-support/fetchzip/tests.nix
  3. 1
      pkgs/test/default.nix
  4. 5
      pkgs/top-level/all-packages.nix

@ -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" ]))

@ -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
# '';
#};
}

@ -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 { };

@ -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 { };

Loading…
Cancel
Save