Is it possible to refer to a home-manager shellAlias in another file using config.home.shellAliases.[alias]? At the moment, attempting to do so results in an infinite recursion, which I’m assuming is because of the attrsOf type.
Share your code and the error.
Here’s a simple example that doesn’t seem to work:
{ config, osLib, ... }: {
home.shellAliases = {
ls = osLib.getExe config.programs.eza.package;
la = "${config.home.shellAliases.ls} -la --octal-permissions";
"." = config.home.shellAliases.la;
".." = "${config.home.shellAliases.cd or "cd"} ..";
};
}
This is the error I’m getting.
Yes, I believe this is the case. Each value in the attrset must be evaluated enough to distinguish that it is not something like mkIf false foo, so that it knows that the key should exist in the attrset, before it can determine the set of keys in the attrset, which it must do before determining the value associated to any key.
This kind of problem is why lazyAttrsOf exists. In general, the different attributes of an attrsOf cannot depend on each other.
Hmm… Any advice on how to get around this, other than patching home-manager? Perhaps make another option using lazyAttrsOf and setting that to shellAliases?
If the settings are in the same file, you can just use a let binding to avoid the recursion. If they’re in different files, you’re going to need to either pass the information through _module.args or create an option to carry the recursive part.
Got it. I’ll try and create a new option first, just to keep things organized. Thanks for the help!