Merge pull request #133350 from rasendubi/fetchzip-downloadname

fetchzip: add extension parameter
This commit is contained in:
Dmitry Kalinkin 2021-08-15 13:04:32 -04:00 committed by GitHub
commit a57ca31b3b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -13,10 +13,17 @@
, urls ? []
, extraPostFetch ? ""
, name ? "source"
, # Allows to set the extension for the intermediate downloaded
# file. This can be used as a hint for the unpackCmdHooks to select
# an appropriate unpacking tool.
extension ? null
, ... } @ args:
(fetchurl (let
basename = baseNameOf (if url != "" then url else builtins.head urls);
tmpFilename =
if extension != null
then "download.${extension}"
else baseNameOf (if url != "" then url else builtins.head urls);
in {
inherit name;
@ -30,7 +37,7 @@ in {
mkdir "$unpackDir"
cd "$unpackDir"
renamed="$TMPDIR/${basename}"
renamed="$TMPDIR/${tmpFilename}"
mv "$downloadedFile" "$renamed"
unpackFile "$renamed"
''
@ -56,7 +63,7 @@ in {
+ ''
chmod 755 "$out"
'';
} // removeAttrs args [ "stripRoot" "extraPostFetch" ])).overrideAttrs (x: {
} // removeAttrs args [ "stripRoot" "extraPostFetch" "extension" ])).overrideAttrs (x: {
# Hackety-hack: we actually need unzip hooks, too
nativeBuildInputs = x.nativeBuildInputs ++ [ unzip ];
})