Hi, I’m just starting with nix and I can’t seems to find how approach to converting a list
of l = [{ foo = "x"; bar = "y"} .... ]
to attribute set
e.g. a = { x = { foo = "x"; bar = "y"; }; ... }
?
I’m trying to populate email accounts in home-manger and this is what I have tried so far
{ lib, pkgs, ... }:
let
servers = {
protonmail = {
imap = {
host = "127.0.0.1";
port = 1143;
tls.enable = true;
tls.useStartTls = true;
};
smtp = {
host = "127.0.0.1";
port = 1025;
tls.enable = true;
};
};
};
accs = [
{
username = "a@b.c";
password = "pass";
name = "name lastname";
}
{
username = "x@y.z";
password = "pass";
name = "name lastname";
}
];
in
{
programs.himalaya = {
enable = true;
settings = { };
};
accounts.email.accounts = lists.forEach accs (x: servers.protonmail // {
realName = x.name;
himalaya.enable = true;
address = x.username;
userName = x.username;
passwordCommand = x.password; #"cat ~/.config/.protonmail.password"; # Temporary password from ProtonMail Bridge
});
}
But it gives me
error: A definition for option `home-manager.users.a.accounts.email.accounts' is not of type `attribute set of submodule'. Definition values:
- In `/nix/store/54a6ai61n39vi8algxhd2p7j2bx8n0nv-source/mail':
[
{
address = "a@b.c";
himalaya = {
....
also I tried to use lib.genAttrs
but no luck yet.
P.S. it is my first time here!