Skip to content

Add nix hash convert#9452

Merged
tomberek merged 13 commits intoNixOS:masterfrom
kolloch:feature/nix-hash-convert
Dec 7, 2023
Merged

Add nix hash convert#9452
tomberek merged 13 commits intoNixOS:masterfrom
kolloch:feature/nix-hash-convert

Conversation

@kolloch
Copy link
Contributor

@kolloch kolloch commented Nov 25, 2023

Motivation

This adds the nix hash convert command as described in #8876.

This does slightly deviate from the proposal: --to defaults to sri.

Context

Open:

  • Better CLI help text with available options.
  • Update docs? Or which part is auto-generated which is not?
  • Clarify whether the base32 vs nix32 hash format name change should be part of this.
  • Verify that the approach to making "--from" AND "--type" AND "--to" optional depending on context is a good choice.
  • Verify that the "--from" parameter strategy is as desired. It is an assert rather than a format hint since it is redundant.

Priorities

Add 👍 to pull requests you find important.

@kolloch kolloch requested a review from edolstra as a code owner November 25, 2023 16:42
@github-actions github-actions bot added new-cli Relating to the "nix" command with-tests Issues related to testing. PRs with tests have some priority labels Nov 25, 2023
Copy link
Contributor

@fricklerhandwerk fricklerhandwerk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool, thanks a lot for helping out! Would be great if you could add a release note. And ideally a deprecation warning on the existing command, but this can be done in a follow-up not to stall progress here if you're short on time.

How exactly does this deviate from the proposal though?

@tomberek
Copy link
Contributor

@kolloch , for your questions and from Nix team

  • Update docs? Or which part is auto-generated which is not?
    • yes, and please add docs
  • Clarify whether the base32 vs nix32 hash format name change should be part of this.
    • yes
  • Verify that the approach to making "--from" AND "--type" AND "--to" optional depending on context is a good choice.
    • yes, if it can be unambiguous
    • please consider changing "--type" into "--algo" (thoughts?), we updated the original issue
  • Verify that the "--from" parameter strategy is as desired. It is an assert rather than a format hint since it is redundant.
    • yes
  • more tests are always wonderful to clarify expected behavior (eg: what was in the comment in the parent issue)

@kolloch kolloch force-pushed the feature/nix-hash-convert branch from da8928a to 1616f0e Compare November 27, 2023 18:38
@github-actions github-actions bot added store Issues and pull requests concerning the Nix store fetching Networking with the outside (non-Nix) world, input locking labels Nov 28, 2023
@kolloch kolloch force-pushed the feature/nix-hash-convert branch from fc7c6c0 to e009c33 Compare November 28, 2023 13:27
@kolloch kolloch changed the title WIP: Add nix hash convert Add nix hash convert Nov 28, 2023
@kolloch
Copy link
Contributor Author

kolloch commented Nov 28, 2023

I think I addressed all the comments.

In addition, I did rename HashType to HashAlgorithm so that the type matches the arguement names of the CLI and the builtin.

I did NOT yet remove the need to specify the nix-command experiment feature.

It would be nice to get this merged in the current form plus eventually needed bug fixes, of course. Meaning: it might still be worth it to add some more docs somewhere but I'd like to do future works in separate merge requests so this doesn't grow unboundedly.

Thank you!

@kolloch kolloch force-pushed the feature/nix-hash-convert branch from b13d967 to 8935e7a Compare November 28, 2023 18:18
@kolloch
Copy link
Contributor Author

kolloch commented Nov 28, 2023

How exactly does this deviate from the proposal though?

The --to format parameter is optional and defaults to SRI.

@kolloch
Copy link
Contributor Author

kolloch commented Nov 28, 2023

Ah, I noticed that my IDE reindented some lines close to some renames. I hope that's fine. It would be quite some pain to undo.

@kolloch kolloch force-pushed the feature/nix-hash-convert branch from 068f565 to 754f20f Compare December 2, 2023 15:38
@kolloch
Copy link
Contributor Author

kolloch commented Dec 2, 2023

I rebase my changes on the latest master :)

@kolloch
Copy link
Contributor Author

kolloch commented Dec 3, 2023

And some further fixes in code that wasn’t executed in make installcheck

@kolloch
Copy link
Contributor Author

kolloch commented Dec 4, 2023

@tomberek anything else?

Copy link
Contributor

@tomberek tomberek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few binaries or unintended things snuck in. The vast majority is changes I presume the compiler is better at checking than I. Otherwise we're looking good.

@kolloch kolloch force-pushed the feature/nix-hash-convert branch from f343d26 to bde30ed Compare December 6, 2023 09:31
@kolloch
Copy link
Contributor Author

kolloch commented Dec 6, 2023

Thank you for checking and finding the added files, @tomberek!

I interactively rebased to make sure that the binary doesn't pollute the history.

Not sure what this is about and if I can do something about it:

https://github.com/NixOS/nix/actions/runs/7112656418/job/19363023090?pr=9452
image

@kolloch kolloch requested a review from tomberek December 6, 2023 09:56
@kolloch kolloch force-pushed the feature/nix-hash-convert branch from bde30ed to 9c6c4ca Compare December 6, 2023 10:00
kolloch and others added 10 commits December 6, 2023 23:43
To be consistent with CLI, nix API
and many other references.

As part of this, we also converted it to a scoped enum.

NixOS#8876
...and also adjusted parsing accordingly.

Also added CLI completion for HashFormats.

NixOS#8876
(But not yet nix-hash since `nix hash` is still hidden behind a feature flag.)

NixOS#8876
Co-authored-by: Théophane Hufschmitt <[email protected]>
"warning: you don'\''t have Internet access; disabling some network-dependent features" ...

NixOS#8876
@kolloch kolloch force-pushed the feature/nix-hash-convert branch from 9c6c4ca to 9a1a3c4 Compare December 6, 2023 22:43
@kolloch
Copy link
Contributor Author

kolloch commented Dec 6, 2023

rebased on latest master

@kolloch
Copy link
Contributor Author

kolloch commented Dec 6, 2023

Somehow it still shows I need to address some review comments but I don't see which...

@tomberek tomberek merged commit 82449a4 into NixOS:master Dec 7, 2023
@Ericson2314
Copy link
Member

Sorry I dropped the ball on this. @tomberek thank you for picking up after me.

@kolloch
Copy link
Contributor Author

kolloch commented Dec 7, 2023

Hurray! Thanks @tomberek

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fetching Networking with the outside (non-Nix) world, input locking new-cli Relating to the "nix" command store Issues and pull requests concerning the Nix store with-tests Issues related to testing. PRs with tests have some priority

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

5 participants