I am trying to generate such an attribute set from a list or colours, by combining it with a list of attribute names (with map). Each step separately works ok (using map, listToAttrs and nameValuePair) but I cannot get the lists to combine the way that is needed.
Could someone shed some light. or point in the right direction?
First, we use lib.zipListsWith to combine the two lists in the form of { name = "..."; value = "..."; }:
[ { name = "base00"; value = "aaccbb"; } { name = "base01"; value = "ff00cc"; } ]
PS:inherit name value; is just a short way to say name = name; value = value;
Next, we pass the result to lib.listToAttrs, which takes a list of { name = "..."; value = "..."; } attributes as input and gives us the combined attribute set as output:
Thank you very much! Ziplist was indeed what I was looking for. And what a great example of how to approach this: a separate file in combination with entr definitely beats goofing around in nix repl. So also thank you for showing how to get better in nix!
I took the liberty to expand on your answer a bit: