Using what I've learned here, PR is up! nix-community/home-manager#1063
If I have an attrset with fixed children (nullOr
), but the name can be anything, like the following:
function /* or func, or fn, anything really */ = {
body = "echo hi"; # nullOr lines
description = "echoes hi"; # nullOr str
on_event = "some_event"; # nullOr str
# not pictured: wraps = null; # nullOr str
};
how would I translate that into the following (a bit pseudocode-y):
{
name = "functions/${function}";
value = {
"text" = ''
function ${function} --description="${function.description}" --on-event "${function.on_event}"
${function.body}
end
'';
};
}
?
Basically, I am trying to add the ability to specify complex functions to home-manager
's fish
module. Its original implementation (found here) is too naive and doesn't support additional flags like above. However, I don't know how I would get from A to B, which functions to use, etc.
The goal is to go from either
func = "echo hi";
or
func = {
body = "echo hi";
on_event = "event";
};
to
function ${name} # --on-event=event for the second one
${body}
end
Maybe something like the following is sufficient;
You can try it out like so, assuming above contents are in default.nix