NixOS / nix

Nix, the purely functional package manager
https://nixos.org/
GNU Lesser General Public License v2.1
12.27k stars 1.48k forks source link

nix-prefetch-url: support SRI hashes directly #10990

Closed eclairevoyant closed 2 weeks ago

eclairevoyant commented 3 months ago

Is your feature request related to a problem? Please describe. Currently, using SRI hashes with nix-prefetch-url require an invocation such as:

nix-prefetch-url <url> --type sha256 | xargs nix hash convert --hash-algo sha256

Describe the solution you'd like It'd be far more convenient to have a flag to output SRI hashes directly, e.g.

nix-prefetch-url <url> --type sha256 --as-sri

Or alternatively, use SRI hashes by default, since they're the preferred type in nixpkgs anyway.

Describe alternatives you've considered see above

Additional context

Priorities

Add :+1: to issues you find important.

Chatchaton commented 2 months ago

having a subcommand nix prefetch-url with --as-sri as the default behavior would be nice

edolstra commented 2 months ago

nix store prefetch-file prints an SRI hash, maybe that works for you?