From c01f657e8d46f213ac5906924ff37013275830e3 Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Thu, 26 Oct 2023 19:36:32 +0100 Subject: [PATCH 1/3] lib: lists: add 'nullableToList' --- lib/lists.nix | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/lists.nix b/lib/lists.nix index 190198e..6c2fadd 100644 --- a/lib/lists.nix +++ b/lib/lists.nix @@ -24,4 +24,10 @@ in # (any -> value) # [ any ] mapFilter = pred: f: attrs: filter pred (map f attrs); + + # Transform a nullable value into a list of zero/one element. + # + # nullableToList :: + # (nullable a) -> [ a ] + nullableToList = x: if x != null then [ x ] else [ ]; } From 3a1ccea1425fdfe60584b6729014d3f12799c87d Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Thu, 26 Oct 2023 19:37:04 +0100 Subject: [PATCH 2/3] home: tmux: add 'trueColorTerminals' This uses the recommended way of enabling true-color [1]. [1]: https://github.com/tmux/tmux/wiki/FAQ#how-do-i-use-rgb-colour --- home/tmux/default.nix | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/home/tmux/default.nix b/home/tmux/default.nix index e554fd0..08aeb55 100644 --- a/home/tmux/default.nix +++ b/home/tmux/default.nix @@ -11,6 +11,19 @@ in enable = my.mkDisableOption "tmux terminal multiplexer"; enablePassthrough = mkEnableOption "tmux DCS passthrough sequence"; + + trueColorTerminals = mkOption { + type = with types; listOf str; + default = lib.my.nullableToList config.my.home.terminal.program; + defaultText = '' + `[ config.my.home.terminal.program ]` if it is non-null, otherwise an + empty list. + ''; + example = [ "xterm-256color" ]; + description = '' + $TERM values which should be considered to always support 24-bit color. + ''; + }; }; config.programs.tmux = lib.mkIf cfg.enable { @@ -75,6 +88,14 @@ in set -g allow-passthrough on '' } + + # Force 24-bit color for each relevant $TERM + ${ + let + mkTcFlag = term: ''set -as terminal-features ",${term}:RGB"''; + in + lib.concatMapStringsSep "\n" mkTcFlag cfg.trueColorTerminals + } ''; }; } From 42ab12179e16e7af7e467365d76607d5ae7ca15f Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Thu, 26 Oct 2023 19:39:44 +0100 Subject: [PATCH 3/3] hosts: homes: mousqueton: use 'trueColorTerminals' Ah, much better with an actual option for this :-). --- hosts/homes/ambroisie@mousqueton/default.nix | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/hosts/homes/ambroisie@mousqueton/default.nix b/hosts/homes/ambroisie@mousqueton/default.nix index ac73da6..7f9d659 100644 --- a/hosts/homes/ambroisie@mousqueton/default.nix +++ b/hosts/homes/ambroisie@mousqueton/default.nix @@ -20,8 +20,6 @@ # I use scripts that use the passthrough sequence often on this host my.home.tmux.enablePassthrough = true; - programs.tmux.extraConfig = '' - # Setup 24-bit color explicitly, as the default terminfo entry does not - set-option -sa terminal-overrides ",xterm-256color:Tc" - ''; + # HTerm uses `xterm-256color` as its `$TERM`, so use that here + my.home.tmux.trueColorTerminals = [ "xterm-256color" ]; }