Nixpkgs: fetchurl/fetchzip fails based on file extension?

Created on 24 Apr 2019  路  11Comments  路  Source: NixOS/nixpkgs

with import <nixpkgs> {};
stdenv.mkDerivation {
   name = "test";
   src = fetchzip {
      name = "cs2d.zip";
      url = "http://www.unrealsoftware.de/get.php?get=cs2d_1008_win.zip&p=1&cid=1266";
      sha256 = "1g66635m8zfsxdmg95c1xz72s6pam9w1myrjwk4dnw697dhpir1p";
      };
}

fails with

trying http://www.unrealsoftware.de/get.php?get=cs2d_1008_win.zip&p=1&cid=1266
unpacking source archive /build/get.php?get=cs2d_1008_win.zip&p=1&cid=1266
do not know how to unpack source archive /build/get.php?get=cs2d_1008_win.zip&p=1&cid=1266

Also my understanding is maybe the result should be renamed to the name attribute?

fetch

Most helpful comment

workaround atm would be:

with import <nixpkgs> {};
stdenv.mkDerivation {
   name = "test";
   src = fetchzip {
      name = "cs2d.zip";
-      url = "http://www.unrealsoftware.de/get.php?get=cs2d_1008_win.zip&p=1&cid=1266";
+      url = "http://www.unrealsoftware.de/get.php?get=cs2d_1008_win.zip&p=1&cid=1266#cs2d.zip";
      sha256 = "1g66635m8zfsxdmg95c1xz72s6pam9w1myrjwk4dnw697dhpir1p";
      };
}

All 11 comments

Alternatively the culprit is https://github.com/NixOS/nixpkgs/blob/ad4f7dd90e098f344114bc8f54ab5025233f1ffe/pkgs/build-support/fetchzip/default.nix#L30

I thought passing curlOpts to fetchzip, which passes it through to fetchurl - might work but the -o option is already taken when downloadToTemp ( https://github.com/NixOS/nixpkgs/blob/ad4f7dd90e098f344114bc8f54ab5025233f1ffe/pkgs/build-support/fetchzip/default.nix#L22 ) is true.

TODO: how is the name argument of fetchzip even used, and how is it expected to be used?
It only seems to get passed through to fetchurl.

@Mic92 Still broken also broken in stable :(

workaround atm would be:

with import <nixpkgs> {};
stdenv.mkDerivation {
   name = "test";
   src = fetchzip {
      name = "cs2d.zip";
-      url = "http://www.unrealsoftware.de/get.php?get=cs2d_1008_win.zip&p=1&cid=1266";
+      url = "http://www.unrealsoftware.de/get.php?get=cs2d_1008_win.zip&p=1&cid=1266#cs2d.zip";
      sha256 = "1g66635m8zfsxdmg95c1xz72s6pam9w1myrjwk4dnw697dhpir1p";
      };
}

or just:

with import <nixpkgs> {};
stdenv.mkDerivation {
   name = "test";
   src = fetchzip {
      name = "cs2d.zip";
-      url = "http://www.unrealsoftware.de/get.php?get=cs2d_1008_win.zip&p=1&cid=1266";
+      url = "http://www.unrealsoftware.de/get.php?p=1&cid=1266&get=cs2d_1008_win.zip";
      sha256 = "1g66635m8zfsxdmg95c1xz72s6pam9w1myrjwk4dnw697dhpir1p";
      };
}

@Mic92 Thanks, I hate it.
(no really, thanks though... facepalm)

Even when downloadedToTemp is set, it might be still possible to fix the file extension:

https://github.com/NixOS/nixpkgs/blob/7a4a8e008988b64059e7b8f1ee5e30c0102a36e4/pkgs/build-support/fetchurl/builder.sh#L25

We just need to replace file with $(basename $out).

Changing the file name to $(basename $out) would require putting the file extension in the package name, which is far from ideal. fetchzip et al are sometimes used to install packages which require no build steps, and the package name in this case is set to name-version as usual.

The unpacker should not check the extension at all. It should simply try unpacking with all available archivers, or consult file or a similar tool that parses file headers.

I marked this as stale due to inactivity. → More info

Has this been fixed?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lverns picture lverns  路  3Comments

yawnt picture yawnt  路  3Comments

sid-kap picture sid-kap  路  3Comments

tomberek picture tomberek  路  3Comments

spacekitteh picture spacekitteh  路  3Comments