Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hplipWIthPlugin: curl for hplip-3.24.4-plugin.run returns error 403 #391727

Closed
3 tasks done
chris3k opened this issue Mar 21, 2025 · 6 comments
Closed
3 tasks done

hplipWIthPlugin: curl for hplip-3.24.4-plugin.run returns error 403 #391727

chris3k opened this issue Mar 21, 2025 · 6 comments
Labels
0.kind: bug Something is broken

Comments

@chris3k
Copy link

chris3k commented Mar 21, 2025

Nixpkgs version

  • Stable (24.11)

Describe the bug

hplip plugin fetch step fails with error 403 when trying to download https://developers.hp.com/sites/default/files/hplip-3.24.4-plugin.run using curl with default user-agent.

To fix this set user-agent to Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.159 Safari/537.36 or download plugin from https://www.openprinting.org/download/printdriver/auxfiles/HP/plugins/

Steps to reproduce

# NIXPKGS_ALLOW_UNFREE=1 nix-shell -p hplipWithPlugin
these 2 derivations will be built:
  /nix/store/3szdhxqbxk0npbf1ihqkdhqb7qidv6gj-hplip-3.24.4-plugin.run.drv
  /nix/store/1bjgqk33yza4qbxdll593aidydwgd223-hplip-3.24.4.drv
building '/nix/store/3szdhxqbxk0npbf1ihqkdhqb7qidv6gj-hplip-3.24.4-plugin.run.drv'...

trying https://developers.hp.com/sites/default/files/hplip-3.24.4-plugin.run
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
curl: (22) The requested URL returned error: 403
error: cannot download hplip-3.24.4-plugin.run from any mirror
error: builder for '/nix/store/3szdhxqbxk0npbf1ihqkdhqb7qidv6gj-hplip-3.24.4-plugin.run.drv' failed with exit code 1
error: 1 dependencies of derivation '/nix/store/1bjgqk33yza4qbxdll593aidydwgd223-hplip-3.24.4.drv' failed to build

Expected behaviour

install hplip with plugin and enter to shell

Screenshots

No response

Relevant log output

Additional context

No response

System metadata

  • system: "x86_64-linux"
  • host os: Linux 6.13.7, NixOS, 24.11 (Vicuna), 24.11.715880.b75693fb46bf
  • multi-user?: yes
  • sandbox: yes
  • version: nix-env (Nix) 2.24.12
  • channels(kg): "unstable"
  • channels(root): "nixos-24.11"
  • nixpkgs: /nix/var/nix/profiles/per-user/root/channels/nixos

Notify maintainers

@ttuegel


Note for maintainers: Please tag this issue in your pull request description. (i.e. Resolves #ISSUE.)

I assert that this issue is relevant for Nixpkgs

Is this issue important to you?

Add a 👍 reaction to issues you find important.

@chris3k chris3k added the 0.kind: bug Something is broken label Mar 21, 2025
@chris3k
Copy link
Author

chris3k commented Mar 21, 2025

this patch fixes the problem, but I am not sure if we want to hardcode user agent

diff --git a/pkgs/by-name/hp/hplip/package.nix b/pkgs/by-name/hp/hplip/package.nix
index 024369818..061f610b4 100644
--- a/pkgs/by-name/hp/hplip/package.nix
+++ b/pkgs/by-name/hp/hplip/package.nix
@@ -45,6 +45,7 @@ let
   plugin = fetchurl {
     url = "https://developers.hp.com/sites/default/files/${pname}-${version}-plugin.run";
     hash = "sha256-Hzxr3SVmGoouGBU2VdbwbwKMHZwwjWnI7P13Z6LQxao=";
+    curlOptsList = ["-A" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.159 Safari/537.36"];
   };
 
   hplipState = replaceVars ./hplip.state {

@scarlet-storm
Copy link
Contributor

I was able to fix this by overriding the user agent as mentioned earlier.
Maybe we can use a mirror instead
https://www.openprinting.org/download/printdriver/auxfiles/HP/plugins/

@scarlet-storm
Copy link
Contributor

Should be fixed by #391529

@psentee
Copy link
Contributor

psentee commented Mar 21, 2025

FWIW, once you prefetch the file into the nix store (e.g. by :b pkgs.fetchurl { …; curlOptsList = […]; } in a nix shell - maybe there's some prefetch script that will do the trick, but this way I was sure the output hash will be same as the one used by the package), the unpatched package builds just fine.

@chris3k
Copy link
Author

chris3k commented Mar 21, 2025

FWIW, once you prefetch the file into the nix store (e.g. by :b pkgs.fetchurl { …; curlOptsList = […]; } in a nix shell - maybe there's some prefetch script that will do the trick, but this way I was sure the output hash will be same as the one used by the package), the unpatched package builds just fine.

as ad-hoc solution this workaround with manual prefetch works for me as well.

@markus1189
Copy link
Contributor

Also used the ad-hoc solution via nix-repl:

pkgs.fetchurl {
  url = "https://developers.hp.com/sites/default/files/hplip-3.24.4-plugin.run";
  hash = "sha256-Hzxr3SVmGoouGBU2VdbwbwKMHZwwjWnI7P13Z6LQxao=";
  curlOptsList = [
    "-A"
    "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.159 Safari/537.36"
  ];
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.kind: bug Something is broken
Projects
None yet
Development

No branches or pull requests

5 participants