Tmux config not being sourced

Hi, I am trying to configure Tmux using Home Manager on Ubuntu, and Tmux is acting very strangely. It loads some parts of my config, such as my prefix, but not my theme and plugins. I’ve tried changing the order to no avail. Not sure if I need to somehow use Tmux Plugin Manager but I have no idea what’s going on. I’ve tried rebuilding home manager, then killing the Tmux server, then restarting but still getting the same results.

{
  pkgs,
  config,
  ...
}: let
  tmux-nerd-font-window-name = pkgs.tmuxPlugins.mkTmuxPlugin {
    pluginName = "tmux-nerd-font-window-name.tmux";
    version = "unstable-2023-08-22";
    rtpFilePath = "tmux-nerd-font-window-name.tmux";
    src = pkgs.fetchFromGitHub {
      owner = "joshmedeski";
      repo = "tmux-nerd-font-window-name";
      rev = "c2e62d394a290a32e1394a694581791b0e344f9a";
      sha256 = "stkhp95iLNxPy74Lo2SNes5j1AA4q/rgl+eLiZS81uA=";
    };
  };
in {
  programs.tmux = {
    enable = true;
    terminal = "tmux-256color";
    baseIndex = 1;
    prefix = "C-x";

    plugins = with pkgs.tmuxPlugins; [
      nord
      vim-tmux-navigator
      tmux-which-key

      {
        plugin = resurrect;
        extraConfig = ''
          set -g @resurrect-strategy-nvim 'session'
          set -g @resurrect-strategy-vim 'session'
          set -g @resurrect-capture-pane-contents 'on'
        '';
      }

      {
        plugin = continuum;
        extraConfig = ''
          set -g @continuum-restore 'on'
          set -g @continuum-save-interval '5'
          set -g @continuum-boot 'on'
        '';
      }

      {
        plugin = tmux-nerd-font-window-name;
        extraConfig = ''
          set -g @plugin 'joshmedeski/tmux-nerd-font-window-name'
        '';
      }
    ];

    extraConfig = ''
      ##### Colors & Terminal #####
      set -ga terminal-overrides ",xterm-256color:Tc"
      set -as terminal-features ",xterm-256color:RGB"

      ##### General #####
      set -g set-clipboard on
      set -g detach-on-destroy off
      set -g escape-time 0
      set -g history-limit 1000000
      set -g mouse on
      set -g status-interval 3
      set -g allow-passthrough on
      set -g status-position top

      ##### Window / Pane Management #####
      set -g base-index 1
      set -g pane-base-index 1
      set -g renumber-windows on
      unbind %
      bind | split-window -h -c "#{pane_current_path}"
      unbind '"'
      bind - split-window -v -c "#{pane_current_path}"
      bind c new-window -c "#{pane_current_path}"

      ##### Resize / Navigation #####
      bind -r j resize-pane -D 5
      bind -r k resize-pane -U 5
      bind -r h resize-pane -L 5
      bind -r l resize-pane -R 5
      bind -r m resize-pane -Z
      setw -g mode-keys vi

      ##### which-key #####
      set -g @tmux-which-key-xdg-enable 1
      set -g @tmux-which-key-disable-autobuild 1

      ##### Reload #####
      bind r source-file ~/.config/tmux/tmux.conf \; display-message "Config reloaded!"

      ##### Theme #####
      run-shell ${pkgs.tmuxPlugins.nord}/share/tmux-plugins/nord/nord.tmux
    '';
  };
}

Hi @1blckhrt ! Welcome to the nixos discourse!

You’r config looks fine to me at a first glance. Can you provide some more information about your setup? What ubuntu version, what shell, …? Also, what does actually end up in the tmux config? have you checked the actual content of ~/.config/tmuc.conf?

Ubuntu 25.04, ZSH, and Nix installed using Determinate Nix. I also have ~/.nix-profile/bin on path if that makes a difference.

The generated tmux config doesn’t seem to have anything out of the ordinary from my config to my knowledge, so I’m not sure what else could be going wrong. I’ve attached it below.

Once I source the config inside tmux, everything but the theme works. In regard to that, I looked at tmux messages using tmux-which-key and it mentions lack of a nord.conf file, even though it should be there. My config exists in ~/nix-config but I have no src directory there.

set  -g default-terminal "tmux-256color"
set  -g base-index      1
setw -g pane-base-index 1





set -g status-keys emacs
set -g mode-keys   emacs



# rebind main key: C-x
unbind C-b
set -g prefix C-x
bind -N "Send the prefix key through to the application" \
  C-x send-prefix




set  -g mouse             off
set  -g focus-events      off
setw -g aggressive-resize off
setw -g clock-mode-style  12
set  -s escape-time       500
set  -g history-limit     2000

# ============================================= #
# Load plugins with Home Manager                #
# --------------------------------------------- #

# tmuxplugin-nord
# ---------------------

run-shell /nix/store/4i7lx1lhya4vwmkla666wwj9xdz41cyn-tmuxplugin-nord-0.3.0-unstable-2023-03-03/share/tmux-plugins/nord/nord.tmux


# tmuxplugin-vim-tmux-navigator
# ---------------------

run-shell /nix/store/rypi573yvrlza1sjsm9ya24784jbzrlq-tmuxplugin-vim-tmux-navigator-unstable-2022-08-21/share/tmux-plugins/vim-tmux-navigator/vim-tmux-navigator.tmux


# tmuxplugin-tmux-which-key
# ---------------------

run-shell /nix/store/qxhkv8042kd8scrpnmmfjxinxh0kn07j-tmuxplugin-tmux-which-key-0-unstable-2024-06-08/share/tmux-plugins/tmux-which-key/plugin.sh.tmux


# tmuxplugin-resurrect
# ---------------------
set -g @resurrect-strategy-nvim 'session'
set -g @resurrect-strategy-vim 'session'
set -g @resurrect-capture-pane-contents 'on'

run-shell /nix/store/9ll73l6sy1wa7i6xg48fwn4wwdbvc8il-tmuxplugin-resurrect-unstable-2022-05-01/share/tmux-plugins/resurrect/resurrect.tmux


# tmuxplugin-continuum
# ---------------------
     set -g @continuum-restore 'on'
     set -g @continuum-save-interval '5'
     set -g @continuum-boot 'on'
set -g @continuum-systemd-start-cmd 'new-session -d'

run-shell /nix/store/pri2dyflycm30zampdayc3y9xsrk3qdk-tmuxplugin-continuum-unstable-2022-01-25/share/tmux-plugins/continuum/continuum.tmux


# tmuxplugin-tmux-nerd-font-window-name.tmux
# ---------------------
set -g @plugin 'joshmedeski/tmux-nerd-font-window-name'

run-shell /nix/store/ws7w1ir2mg5p7f2c32q9p2fmgjknmxp3-tmuxplugin-tmux-nerd-font-window-name.tmux-unstable-2023-08-22/share/tmux-plugins/tmux-nerd-font-window-name.tmux/tmux-nerd-font-window-name.tmux

# ============================================= #

##### Colors & Terminal #####
set -ga terminal-overrides ",xterm-256color:Tc"
set -as terminal-features ",xterm-256color:RGB"

##### General #####
set -g set-clipboard on
set -g detach-on-destroy off
set -g escape-time 0
set -g history-limit 1000000
set -g mouse on
set -g status-interval 3
set -g allow-passthrough on
set -g status-position top

##### Window / Pane Management #####
set -g base-index 1
set -g pane-base-index 1
set -g renumber-windows on
unbind %
bind | split-window -h -c "#{pane_current_path}"
unbind '"'
bind - split-window -v -c "#{pane_current_path}"
bind c new-window -c "#{pane_current_path}"

##### Resize / Navigation #####
bind -r j resize-pane -D 5
bind -r k resize-pane -U 5
bind -r h resize-pane -L 5
bind -r l resize-pane -R 5
bind -r m resize-pane -Z
setw -g mode-keys vi

##### which-key #####
set -g @tmux-which-key-xdg-enable 1
set -g @tmux-which-key-disable-autobuild 1

##### Reload #####
bind r source-file ~/.config/tmux/tmux.conf \; display-message "Config reloaded!"

I checked your config on nixos, and it works fine. Could you maybe try this instead:

...
in {
  programs.tmux = {
    enable = true;

    plugins = with pkgs.tmuxPlugins; [
      vim-tmux-navigator
      tmux-which-key

      {
        plugin = nord;
      }

}

Maybe also remove the custom run-shell commnad you have at the end. As mentioned here (Tmux - NixOS Wiki):

Each of the tmux plugin is run via run-shell automatically.

Tried that and basically got the same results, the status bar is just the regular Tmux one. I checked to make sure I didn’t have a tmux config at ~/.tmux.conf as well, no dice.

Also I do not have a config file here, the one that is generated is at ~/.config/tmux/tmux.conf.

I used the same config on a different system (running EndeavourOS + Determinate Nix) and that works fine.

Yeah sorry, I meant your tmux home-manager module.

Just looking at your config again, it seems to be wanting to load a conf file from your config dir, which is not present. Are you sure, you are not loading a conf file somewhere else in your configuration? maybe do a ripgrep and check. The conf file should be in the nix-store, and not in your config folder, unless you specify it explicitly:

Your terminal output says this:

...
message: /home/blckhrt/nix-config/src/nord-status-content.conf: No such file or directory  
...

While my theme conf file is like this:

...
source-file /nix/store/hhngx3z45m82141gbavf94xcaa7nav8b-base16-ayu-mirage.conf
...

Yeah, I checked with ripgrep for “.conf” and “nord”, no results came up in my tmux config for those other than ones in nonrelated files. I do not have an src dir in my config. Another bit of setup context, I use a makefile to run home-manager switch.

Here is my full config if that helps:

(tmux file) → nix-config/common/tmux/default.nix at dca8f5c25e2fb908259a5c40f4767ff63b232b89 · 1blckhrt/nix-config · GitHub

I was able to get it load manually by running bash <nix store path to nord.tmux>, but I’m still not sure why it doesn’t load on tmux boot.

tmuxPlugins.nord: plugin doesn't load if /bin/sh is not bash · Issue #429284 · NixOS/nixpkgs · GitHub might be the source of this issue. I am running Ubuntu and ZSH, so I think I’m out of luck unless I can find a way to change the nord tmux script inside Home Manager

Fixed using this piece of code, the issue is not due to my config, rather a weird quirk with Ubuntu.

{
        plugin = nord.overrideAttrs (old: {
          postInstall =
            (old.postInstall or "")
            + ''
              # Ensure the script has a proper bash shebang
              if ! head -n1 $out/share/tmux-plugins/nord/nord.tmux | grep -q '^#!/usr/bin/env bash'; then
                sed -i '1s|^#!.*|#!/usr/bin/env bash|; t; 1s|^|#!/usr/bin/env bash\n|' \
                  $out/share/tmux-plugins/nord/nord.tmux
              fi
            '';
        });
      }
}