I want to create a list of directories that are stored in settings.github-accounts
. This is a variable defined and import to my flex.
settings.nix
{
username = "foo";
github-accounts = [
{
username = "bar";
email = "bar@exampale.com";
}
{
username = "baz";
email = "baz@example.com";
}
];
}
I want to use this variable and loop over it and create a directory for each account. (I’m using home.activation
for this. If there’s something better and more declarative, please let me know.) I came up with something like this below, but this apparently does not work.
home.nix
home.activation = {
init = lib.hm.dag.entryAfter [ "writeBoundary" ] ''
${builtins.map(account: "mkdir -p ~/projects/${account.username}") settings.github-accounts}
'';
};
I get this error. But why?
error:
… while calling the 'derivationStrict' builtin
at /builtin/derivation.nix:9:12: (source not available)
… while evaluating derivation 'home-manager-generation'
whose name attribute is located at /nix/store/lwyjz70qh12nq6cb7fixl85vryzxqm3c-source/pkgs/stdenv/generic/make-derivation.nix:353:7
… while evaluating attribute 'buildCommand' of derivation 'home-manager-generation'
at /nix/store/lwyjz70qh12nq6cb7fixl85vryzxqm3c-source/pkgs/build-support/trivial-builders/default.nix:98:16:
97| enableParallelBuilding = true;
98| inherit buildCommand name;
| ^
99| passAsFile = [ "buildCommand" ]
(stack trace truncated; use '--show-trace' to show the full trace)
error: cannot coerce a list to a string