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?
The main culprit seems to be https://github.com/NixOS/nixpkgs/blob/f81ddbf8e7889e63496d3263f4ce28e5f9c79269/pkgs/tools/archivers/unzip/setup-hook.sh#L3
which is called by https://github.com/NixOS/nixpkgs/blob/28a95c4f7f1c46399e8938d7f3e08169cda61191/pkgs/stdenv/generic/setup.sh#L845
If we want to keep this behaviour maybe fetchurl should get some additional phases?
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:
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?
Most helpful comment
workaround atm would be: