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

Change hash attr to algo agnostic one (sha256 -> hash, cargoSha256 -> cargoHash) #209

Closed
wants to merge 1 commit into from

Conversation

Kranzes
Copy link

@Kranzes Kranzes commented Nov 25, 2023

As requested previously in #177, this change can help with minimizing the nitpicks on new nixpkgs PRs because of the new fetchers' hash attribute name conventions.

This works for:

  • sha256 -> hash
  • cargoSha256 -> cargoHash
  • vendorSha256 -> vendorHash
  • and more

Note: It currently only supports sha256 hashes as I saw that in a couple of lines below we only get the hash for sha256 anyway, also, the other algorithms aren't that popular anyway.

@Kranzes
Copy link
Author

Kranzes commented Nov 25, 2023

Do I need to change anything in the tests?

@Mic92
Copy link
Owner

Mic92 commented Dec 12, 2023

I don't think I want nix-update to also refactor the code. Replacing hashes is somewhat reliable because they are practically unique but replacing random sha256 = variables could replace instances it shouldn't replace. I think for that it's better to have a tool that understand the language and picks up what a fetcher call is rather just doing search and replace.

@Mic92 Mic92 closed this Dec 12, 2023
@Kranzes
Copy link
Author

Kranzes commented Dec 12, 2023

Fair. I guess while at it also close the issue about this? Btw, isn't --format refactoring too in some sense?

replacing random sha256 = variables could replace instances it shouldn't replace

So far it has been pretty reliable to me... 🤷‍♂️

@Kranzes Kranzes deleted the hash-attr-name branch December 12, 2023 14:11
@Mic92
Copy link
Owner

Mic92 commented Dec 13, 2023

Yes but --format is using a reliable nix formatter that has support for nix syntax on AST level rather than just doing substitution. Here an example:

  some-package = some-generic-builder {
    sha256 = "foo";
  };

We sometimes have builder functions i.e. postgres where we maintain multiple versions of the same program. Those function may not accept hash but only sha256 as an input and would be broken as a result of this. Even if we fix this in every instance in nixpkgs there are still third-party repos that also can use nix-update.

@Mic92
Copy link
Owner

Mic92 commented Dec 13, 2023

You can just make yourself a wrapper that uses sed on all git-modified files to do the replacement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants