summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArtturin <Artturin@artturin.com>2022-05-17 21:49:33 +0300
committerArtturin <Artturin@artturin.com>2022-05-22 21:18:52 +0300
commit5a6a31e54ddaf59aa8e1c5e7e9b02623d4881c34 (patch)
tree65a7186d7a24229aa796c383623efe6ddc909f19
parent7283d3942f7947949a131cfa81e5fd0688af3de3 (diff)
fetchzip: extraPostFetch -> postFetch && tests
-rw-r--r--pkgs/build-support/fetchzip/default.nix8
-rw-r--r--pkgs/build-support/fetchzip/tests.nix25
-rw-r--r--pkgs/test/default.nix1
-rw-r--r--pkgs/top-level/all-packages.nix5
4 files changed, 37 insertions, 2 deletions
diff --git a/pkgs/build-support/fetchzip/default.nix b/pkgs/build-support/fetchzip/default.nix
index a3f22de58c71..98c410370746 100644
--- a/pkgs/build-support/fetchzip/default.nix
+++ b/pkgs/build-support/fetchzip/default.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" ]))
diff --git a/pkgs/build-support/fetchzip/tests.nix b/pkgs/build-support/fetchzip/tests.nix
new file mode 100644
index 000000000000..1ee2d0e7a49c
--- /dev/null
+++ b/pkgs/build-support/fetchzip/tests.nix
@@ -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
+ # '';
+ #};
+}
diff --git a/pkgs/test/default.nix b/pkgs/test/default.nix
index 2ab03bda8b77..d6e4c545a087 100644
--- a/pkgs/test/default.nix
+++ b/pkgs/test/default.nix
@@ -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 { };
diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix
index 6707508cc04f..a5347b836b99 100644
--- a/pkgs/top-level/all-packages.nix
+++ b/pkgs/top-level/all-packages.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 { };