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

Add nix hash convert #9452

Merged
merged 13 commits into from
Dec 7, 2023
Merged

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.

@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?

.gitignore Outdated Show resolved Hide resolved
src/nix/hash.cc Outdated Show resolved Hide resolved
src/nix/hash.cc Outdated Show resolved Hide resolved
tests/functional/hash.sh Outdated Show resolved Hide resolved
@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)

@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 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
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
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.

src/libexpr/tests/libnixexpr-tests Outdated Show resolved Hide resolved
doc/manual/src/release-notes/rl-next.md Outdated Show resolved Hide resolved
@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 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 <7226587+thufschmitt@users.noreply.github.com>
"warning: you don'\''t have Internet access; disabling some network-dependent features" ...

NixOS#8876
@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
8 checks passed
@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