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

lib/attrsets: Add more ways to map over/to attrsets #197004

Closed
wants to merge 1 commit into from

Conversation

dali99
Copy link
Member

@dali99 dali99 commented Oct 21, 2022

These functions have been particularly useful while developing nixos modules

Description of changes
Things done
  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandbox = true set in nix.conf? (See Nix manual)
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 22.11 Release Notes (or backporting 22.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
    • (Release notes changes) Ran nixos/doc/manual/md-to-db.sh to update generated release notes
  • Fits CONTRIBUTING.md.

@ofborg ofborg bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 1-10 labels Oct 21, 2022
@nixos-discourse
Copy link

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

https://discourse.nixos.org/t/prs-ready-for-review/3032/1463

lib/attrsets.nix Outdated Show resolved Hide resolved
@dali99 dali99 force-pushed the lib-mapattrs branch 2 times, most recently from ac28ec3 to 30b1a82 Compare February 27, 2023 13:42
@SuperSandro2000 SuperSandro2000 removed their request for review April 11, 2023 20:04
These functions have been particularly useful while developing nixos modules

Co-authored-by: h7x4 <[email protected]>
will be automatically incremented, starting from 0.

Example:
imapAttrs' (i: name: value: nameValuePair "${name}${toString i}" value + i)
Copy link
Contributor

Choose a reason for hiding this comment

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

Both functions have the same signature? If so, what is the difference between them?

Copy link
Member Author

Choose a reason for hiding this comment

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

they apply f in different places, see the examples:

imapAttrs has a built in nameValuePair, calling f on just the value, you can't change the names from the input attrset.
imapAttrs' wants a function that provides a nameValuePair, so you can modify both the name and the value of the input attrset.

@infinisil
Copy link
Member

I think this is a good change generally, but each function should have:

  • A separate PR, so we can merge it more incrementally. In particular imapAttrs would be great on its own, whereas the others might need more design discussion
  • A type for each function (just add a Type: as with the other lib functions)
  • Tests

@infinisil infinisil added the 6.topic: lib The Nixpkgs function library label Aug 9, 2023
@dali99
Copy link
Member Author

dali99 commented Nov 26, 2023

Replaced by #270049 and #270127

@dali99 dali99 closed this Nov 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.topic: lib The Nixpkgs function library 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 1-10
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants