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

nix hash path, text hashing for nix store add, and preparatory refactors #9815

Merged
merged 1 commit into from
Feb 22, 2024

Conversation

Ericson2314
Copy link
Member

@Ericson2314 Ericson2314 commented Jan 20, 2024

Motivation

Finish #8876

Context

  • nix store add supports text hashing

    With functional test ensuring it matches builtins.toFile.

  • Factored-out flags for both

  • Move all common reusable flags to libcmd

    • They are not part of the definition of the CLI infra, just a usage
      of it.

    • The new libstore flag couldn't go in args.hh in libutil anyways,
      would be awkward for it to live alone separate from the others

  • Shuffle around Cmd* hierarchy so flags for deprecated commands don't end up on the new ones

Priorities and Process

Add 👍 to pull requests you find important.

The Nix maintainer team uses a GitHub project board to schedule and track reviews.

@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 Jan 20, 2024
Ericson2314 added a commit to obsidiansystems/nix that referenced this pull request Jan 20, 2024
@github-actions github-actions bot added the store Issues and pull requests concerning the Nix store label Jan 21, 2024
@Ericson2314 Ericson2314 marked this pull request as ready for review January 21, 2024 03:05
@Ericson2314 Ericson2314 changed the title nix hash path nix hash path, and preperatory refactors Jan 21, 2024
@Ericson2314 Ericson2314 changed the title nix hash path, and preperatory refactors nix hash path, text hasing for nix store add, and preperatory refactors Jan 21, 2024
@Ericson2314 Ericson2314 mentioned this pull request Jan 21, 2024
8 tasks
@Ericson2314 Ericson2314 force-pushed the nix-hash-path branch 2 times, most recently from 19095bd to 61e7690 Compare January 22, 2024 15:17
src/libutil/args.cc Outdated Show resolved Hide resolved
@thufschmitt
Copy link
Member

Discussed during the Nix maintainers meeting on 2024-01-22.
Approved, provided it's made explicit that it's an advanced thing.

- @edolstra: Is exposing `text` really good? - @Ericson2314: If it exists, I think we should exposed it even if it has some warnings/deprecations/etc. - @roberth: Document that it is not needed for users. Recommend that they just use `flat`. It needs to be kept around for the Nix language.

@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/2024-01-22-nix-team-meeting-minutes-117/38838/1

@Ericson2314
Copy link
Member Author

I updated the docs to make more clear that text is advanced users only. If would be nice if someone could approve this! :)

@thufschmitt thufschmitt mentioned this pull request Jan 29, 2024
86 tasks
@thufschmitt thufschmitt self-assigned this Jan 29, 2024
@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/2024-01-30-nix-team-meeting-minutes-119/39185/1

@thufschmitt
Copy link
Member

I'm afraid this is way too many unrelated things for me to review at once. Please split that so that it's possible to make sense of the various parts

@Ericson2314 Ericson2314 changed the base branch from master to 2.20-maintenance February 13, 2024 19:42
@Ericson2314 Ericson2314 changed the base branch from 2.20-maintenance to master February 13, 2024 19:42
@Ericson2314
Copy link
Member Author

Sigh, I was hoping the comments I left would ameliorate that. I have no split off prep PRs and gotten them merged, so I hope this is small enough.

Copy link
Member

@thufschmitt thufschmitt left a comment

Choose a reason for hiding this comment

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

This is a mixed bag of several things, trying to split them up here:

  • I don't really get the point of moving the hash arguments to libcmd
  • The addition of text hashing is good, although it's weird to have both fileIngestionMethod and contentAddressMethod (at least that would require some explanatory comment if there's really a reason to keep them both)
  • The proper split of nix hash path and nix hash file is good too, with the caveat that it should be done more strictly (can be a follow-up) like giving them a proper documentation, and restricting nix hash file to only files

src/libcmd/misc-store-flags.cc Outdated Show resolved Hide resolved
src/libcmd/misc-store-flags.hh Show resolved Hide resolved
src/nix/hash.cc Outdated
Comment on lines 100 to 124
addFlag({
.longName = "sri",
.description = "Print the hash in SRI format.",
.handler = {&hashFormat, HashFormat::SRI},
});

addFlag({
.longName = "base64",
.description = "Print the hash in base-64 format.",
.handler = {&hashFormat, HashFormat::Base64},
});

addFlag({
.longName = "base32",
.description = "Print the hash in base-32 (Nix-specific) format.",
.handler = {&hashFormat, HashFormat::Nix32},
});

addFlag({
.longName = "base16",
.description = "Print the hash in base-16 format.",
.handler = {&hashFormat, HashFormat::Base16},
});

addFlag(flag::hashAlgo("type", &hashAlgo));
Copy link
Member

Choose a reason for hiding this comment

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

If they are deprecated, I think they should be marked as such

src/nix/hash.cc Show resolved Hide resolved
src/nix/hash.cc Outdated
Comment on lines 100 to 124
addFlag({
.longName = "sri",
.description = "Print the hash in SRI format.",
.handler = {&hashFormat, HashFormat::SRI},
});

addFlag({
.longName = "base64",
.description = "Print the hash in base-64 format.",
.handler = {&hashFormat, HashFormat::Base64},
});

addFlag({
.longName = "base32",
.description = "Print the hash in base-32 (Nix-specific) format.",
.handler = {&hashFormat, HashFormat::Nix32},
});

addFlag({
.longName = "base16",
.description = "Print the hash in base-16 format.",
.handler = {&hashFormat, HashFormat::Base16},
});

addFlag(flag::hashAlgo("type", &hashAlgo));
Copy link
Member

Choose a reason for hiding this comment

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

I'm not clear why these are kept for nix hash file and not nix hash path. Both commands accept them similarly right now, so we should either drop them for both, or (preferably) keep them for both. But keeping them for only one seems weird and inconsistent. Or am I missing something?

@Ericson2314
Copy link
Member Author

I don't really get the point of moving the hash arguments to libcmd

Just checking, did you read what I wrote in the PR description? I am happy to elaborate if it still doesn't make sense.

- `nix store add` supports text hashing

  With functional test ensuring it matches `builtins.toFile`.

- Factored-out flags for both commands

- Move all common reusable flags to `libcmd`

  - They are not part of the *definition* of the CLI infra, just a usag
    of it.

  - The `libstore` flag couldn't go in `args.hh` in libutil anyways,
    would be awkward for it to live alone

- Shuffle around `Cmd*` hierarchy so flags for deprecated commands don't
  end up on the new ones
@thufschmitt
Copy link
Member

Just checking, did you read what I wrote in the PR description? I am happy to elaborate if it still doesn't make sense.

It makes sense, it just feels like a very heavy hammer for the small change

@Ericson2314
Copy link
Member Author

@thufschmitt is #9815 (comment) satisfactory? Are there any other outstanding issues?

@thufschmitt
Copy link
Member

@thufschmitt is #9815 (comment) satisfactory? Are there any other outstanding issues?

Nah, looks good. Let's merge!

@thufschmitt thufschmitt merged commit 6a5210f into master Feb 22, 2024
15 checks passed
@thufschmitt thufschmitt deleted the nix-hash-path branch February 22, 2024 16:15
@Ericson2314
Copy link
Member Author

Thank you!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

4 participants