Conversation
|
@ofborg test misc |
It makes few to no sense. You are creating a function that supersedes a function that already exists. Why the duplication? |
|
@AndersonTorres to be honest, I didn't know how averse we - the nix community - were towards changing such a base function. It's my first time touching that part of the code. Essentially, I feared that this would introduce breaking changes because the function will return something else. I agree though that having only one function is better for plenty of reasons and I'm happy you're pushing towards to that! So I'll update the PR. |
98b12a5 to
8c65a99
Compare
|
Checked locally by running |
|
@AndersonTorres Nixpkgs
Similar does not mean equivalent, and identical signatures are not that significant.
This could be considered disrespectful. @ibizaman Your intuition about changes in |
|
@roberth I don't mind at all reverting to my original PR. It's going to be less scary, for sure. Especially with the failing test there. Should I wait for more feedback though? |
|
As another main Changing lib.mapAttrsRecursive (as: value:
if lib.isList value then
value ++ [ 3 ]
else
value + 3
) { a = [ 10 ]; b = 20; }Before this PR, this expression evaluates to: { a = [ 10 3 ]; b = 23; }After: { a = [ 13 ]; b = 23; }So I definitely don't think this would be okay. |
infinisil
left a comment
There was a problem hiding this comment.
I'm not a fan of using ' for naming. How about just lib.mapRecursiveCond? Because it won't be specific to attrsets anymore. Still fine to put it under lib.attrsets though, we don't really have a better place for it right now :)
lib/attrsets.nix
Outdated
There was a problem hiding this comment.
| then imap0 (i: v: recurse (path ++ [(toString i)]) v) value | |
| then imap0 (i: v: recurse (path ++ [i]) v) value |
Otherwise we can't distinguish between { "0" = 1; } and [ 1 ] when recursing, because both would have "0" in the path. Passing through the integer without converting to a string makes it clear that integer path entries come from lists.
Understood.
I was not meant to be disrespectful. Regardless, apologies for my bad take. |
There's still potential for more to be transformed: function return values, so this name may be too general. I don't think it aligns particularly well with the goal of the function, so how about
I agree. I wouldn't mind something like |
This new 'mapDataRecursiveCond' function is like 'mapAttrsRecursiveCond' and additionally recurses on lists. This function will be used with user-provided freeform variables - arbitrary combinations of attrset, lists and values - in the upcoming secret management feature. The PR NixOS#328472 shows how it will be used.
8c65a99 to
20892d0
Compare
|
Could you pass |
infinisil
left a comment
There was a problem hiding this comment.
This is looking great overall, I'm happy to merge once the feedback is addressed :D
Sidenote: To avoid further minor review iterations once the feedback is addressed, I'd like to promote the workflow of reviewers pushing to PRs directly if the PR is almost ready, but they're still unhappy with something minor :)
I like that too, but it's not always the best option
Sometimes a branch can't be pushed to by maintainers. Look for "Maintainers are allowed to edit this pull request" on the PR page. All that said, it is generally a nicer experience 👍 |
|
@infinisil @roberth I should have answered to all your comments. I did create small commits instead of rebasing for a better review experience in GitHub but I'll squash it all when we're done. |
Description of changes
This new 'mapDataRecursiveCond' function is like 'mapAttrsRecursiveCond' and additionally recurses on lists.
This function will be used with user-provided freeform variables - arbitrary combinations of
attrset, lists and values - in the upcoming secret management feature. The PR #328472 shows how it will be used.
The test
testMapAttrRecursiveDocis taken verbatim from the documentation of that function. I added it as some kind of regression test.Things done
nix.conf? (See Nix manual)sandbox = relaxedsandbox = truenix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/)Add a 👍 reaction to pull requests you find important.