nix-community / home-manager

Manage a user environment using Nix [maintainer=@rycee]
https://nix-community.github.io/home-manager/
MIT License
6.99k stars 1.81k forks source link

bug: tmux with 'sensibleOnTop' option no longer uses the correct shell #5952

Open cixel opened 3 weeks ago

cixel commented 3 weeks ago

Are you following the right branch?

Is there an existing issue for this?

Issue description

The upstream version of tmux was updated last week to 3.5a (commit). One of the changes in this version (from 3.5) is that /bin/sh is used for run-shell.

With this version of tmux, all panes/windows/etc use sh instead of the configured default shell (in my case, zsh).

My rough guess is that this change in tmux has introduced some ordering issues when sensibleOnTop is set, as run-shell will now use sh regardless of how tmux's default-shell is set.

The problem goes away if I do:

  package = pkgs.tmux.overrideAttrs (old: rec {
    version = "3.5";
    src = pkgs.fetchFromGitHub {
      owner = "tmux";
      repo = "tmux";
      rev = version;
      hash = "sha256-8CRZj7UyBhuB5QO27Y+tHG62S/eGxPOHWrwvh1aBqq0=";
    };
  });

or if I set sensibleOnTop = false;

Maintainer CC

@jorsn @rycee (cc based on https://github.com/nix-community/home-manager/commit/a7cdfaa32585fce404cf8890bae099348e53e0ad).

System information

- system: `"aarch64-darwin"`
 - host os: `Darwin 23.6.0, macOS 14.7`
 - multi-user?: `yes`
 - sandbox: `no`
 - version: `nix-env (Nix) 2.18.8`
 - channels(ehdens): `"home-manager, nixpkgs"`
 - nixpkgs: `/Users/ehdens/.nix-defexpr/channels/nixpkgs`
x123 commented 2 weeks ago

I'm also experiencing the same issue. The notes for tmux 3.5a here https://github.com/tmux/tmux/issues/4162 say the following:

"Note that a fix in 3.5 and 3.5a to correctly set SHELL for run-shell and if-shell reveals a bug in the tmux-sensible script, causing it to set default-shell to /bin/sh. This can be worked around by adding this to .tmux.conf after the tmux-sensible script is invoked:"

 - system: `"aarch64-darwin"`
 - host os: `Darwin 24.0.0, macOS 15.0.1`
 - multi-user?: `yes`
 - sandbox: `no`
 - version: `nix-env (Nix) 2.18.8`
 - channels(root): `"nixpkgs"`
 - nixpkgs: `/nix/store/60sn02zhawl3kwn0r515zff3h6hg6ydz-source`

EDIT: Using the following in extraConfig to make sure it's run after tmux-sensible loads seems to fix the issue on darwin and is the updated recommendation from https://github.com/tmux/tmux/issues/4162#issuecomment-2412201969

set -gu default-command
set -g default-shell "$SHELL"
gshpychka commented 2 weeks ago

Same here. Having set -g default-shell "$SHELL" as the last line in my tmux.conf does not fix the issue, only disabling the sensible plugin by setting sensibleOnTop to false does.

EDIT: using set -g default-command "$SHELL" does fix the issue on darwin (with the sensible plugin enabled)

nixos-discourse commented 1 week ago

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/tmux-use-bash-instead-defined-zsh-in-home-manager/54763/2

YorikSar commented 1 day ago

Quick and (very) dirty workaround for this:

  nixpkgs.overlays = [
    (final: prev: {
      tmuxPlugins = prev.tmuxPlugins // {
        sensible = prev.tmuxPlugins.sensible.overrideAttrs (prev: {
          postInstall = prev.postInstall + ''
            sed -e 's:\$SHELL:/bin/zsh:g' -i $target/sensible.tmux
          '';
        });
      };
    })
  ];

It hardcodes /bin/zsh (replace it with what you like to use) and rebuilds tmux-sensible with it.