No colors in foot when SSHing to a NixOS system

Foot is a nice terminal emulator that I use.

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.

Has anyone ever experienced this?

1 Like

Are you sure this is the culprit? The terminfo output of everything that has it seems to be installed by default: https://github.com/NixOS/nixpkgs/blob/84d981bae8b5e783b3b548de505b22880559515f/nixos/modules/config/terminfo.nix#L50

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!

$TERM should 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.

2 Likes

I use foot, and in my home-manager config, place the following:

  programs.foot = {
    enable = true;
    settings = {
      main = {
        term = "xterm-256color";
      }
    }
  }

As @TLATER points out, it isn’t the right thing to do, but it does work quite well.

LOL that’s true.

I do have this file on my system.

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.

Another solution is to do

programs.bash.interactiveShellInit = "TERM=xterm-265";

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:

services.openssh.extraConfig = ''
  AcceptEnv COLORTERM
  '';
1 Like