How to change the user-agent used by fetchurl?

I’d like to package an unfree software, but the website blocks download request with fetchurl’s default user-agent. It’s fine for local user because I could manually download the binaries and add it to nix store, but what if I want to add it to upstream nixpkgs?

I think I could use requireFile.

You could do that. Alternatively you could perhaps write a src derivation that uses curl to download the file.

It’s fine for local user because I could manually download the binaries and add it to nix store, but what if I want to add it to upstream nixpkgs?

There is curlOpts argument to fetchurl, you can use it to set the User Agent header.

(In principle, some packages in Nixpkgs use requireFile so their src has to be downloaded manually and added to store, just like you describe, but it can cause some discussion whether it is worth it adding such a package to mainline and not to an overlay repo in NUR)

2 Likes