Skip to content

Support base-64 and SRI in nix-hash #7688

@ShamrockLee

Description

@ShamrockLee

Is your feature request related to a problem? Please describe.
SRI hashes are becoming more and more popular. It enables the use of hash attribute to pass the hash to the fetcher, making it easier to switch to a safer algorithm in the future. Besides, the base-64 coding is more standardized than the base-32 coding.

The Nix command-line interface currently provide support through

nix hash file --base64 path/to/file
nix hash file --sri path/to/file
nix hash path --base64 path/to/file
nix hash path --sri path/to/file
nix hash to-base64 theHash
nix hash to-sri theHash

but that requires enabling the nix-command experimental feature.

Describe the solution you'd like

nix-hash [--flat] --base64 path/to/file
nix-hash [--flat] --sri path/to/file
nix-hash --to-base64 theHash
nix-hash --to-sri theHash

Describe alternatives you've considered
Do nothing and keep forcing the non-flakers to type

nix --extra-experimental-features nix-command nix hash ...

Additional context
Eelco Dostra's comment recommending the use of SRI hashes: #4354 (comment)
Théo Zimmermann's comment about the lack of this feature NixOS/rfcs#131 (comment)
A Nix RFC proposal (0131) to enforce the use of SRI hashes: NixOS/rfcs#131

Priorities

Add 👍 to issues you find important.

Metadata

Metadata

Assignees

No one assigned

    Labels

    cliThe old and/or new command line interfacefeatureFeature request or proposalnew-cliRelating to the "nix" command

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions