However its $TERM is not xterm-256color but just foot.
That is why for proper functioning, like highlighting ls colors the host usually needs to have a foot-terminfo package installed.
On Nix there is no such package, but one of the outs is terminfo.
I used environment.systemPackages = [pkgs.foot.terminfo] but the foot terminal still does not work.
Maybe check if the terminfo is already in /run/current-system/sw/share/terminfo/f/foot. It appears to be in mine even though I don’t even have foot installed!
$TERMshould not be set to xterm-256color unless you’re using xterm-256color, but AIUI a lot of applications don’t interpret anything other than xterm-256color as capable of a bunch of features irrespective of terminfo, so a lot of inits just set it to xterm-256color anyway.
I am not sure I understand. Are you saying that for some software it’s xterm-256 or a dumb terminal?
I know this works and isn’t the /right/ way to do it.
I would like to avoid setting this setting application wide.
Of course I can overwrite the default $TERM on my nixbox but I wonder if there is ome better way to do it.
Yep. A lot of applications don’t particularly care what terminfo says, and just special case for xterm-256 to allow color codes. terminfo is a pain to parse and not everybody puts that effort in; their codes are the defacto standard anyway.
dircolors does not support foot explicitly, but relies on foot setting the COLORTERM env variable instead:
2022-02-15 Pádraig Brady
dircolors: consider COLORTERM as well as TERM env vars
COLORTERM is an environment used usually to expose truecolor support in
terminal emulators. Therefore support matches on that in addition
to TERM. Also set the default COLORTERM match pattern so that
we apply colors if COLORTERM is any value.
This implicitly supports a terminal like "foot"
without a need for an explicit TERM entry.
For this to work over SSH you need to configure sshd on the NixOS server to accept the COLORTERM environment variable sent by the client: