Lose nix dev shell path and timezone when Tmux starts

Hi!

I’m working on a project inside a devshell. The devshell doesn’t throw anything weird when I run it with nix-shell shell.nix command. My go package is built, the terminal output is fine and which cslsp where cslsp is a custom lsp I started writing throws the right nix store path. Oddly though, cslsp simply dissapears when I apply a custom tmux layout I use for coding to have my text editor and lazygit at hand reach. Why’s that? I never run a line that changes anything in nushell to not be able to find cslsp again.

ide_layout.conf (tmux script)

%if "#{==:#{window_panes},1}"
rename-window ide
splitw -h -p 65 "hx"
splitw -h -p 40
send-keys "lazygit" ENTER
selectp -t 0 
send-keys "w3m duckduckgo.com" ENTER
splitp -v -p 50 
selectp -t 2
%else
display-message "Windows must not be splitted already"
%endif

shell.nix

{pkgs ? import <nixpkgs>{}}:  
pkgs.mkShell {
  packages = with pkgs; [
    go gopls golangci-lint delve gotools 
  ]; 
  buildInputs = with pkgs; [ (callPackage ./lspbuilder.nix {})];
  hardeningDisable = ["fortify"];
  shellHook = ''nu'';
}

lspbuilder.nix

{buildGoModule}:
buildGoModule(finalAttrs: {
  pname = "cslsp";
  version = "0.1";

  src = ./.;
  vendorHash = null;
})

Most likely one of tmux or nushell fails to inherit or pass on the environment set up by nix-shell. You can confirm this by just looking at the contents of $env in both panes, the latter would be missing a bunch of nix-shell specific variables.

My money’s on tmux - you’re probably passing along the environment of tmux itself, rather than the pane you’re running nix-shell in.

There probably is a way to force tmux to copy over the environment of the currently open pane, but I never personally looked at the tmux tomes much. Have a look through their documentation for something like that.

1 Like

Thanks for taking time! I agree with you, tmux fails to pass nix-dev environment. Why? Cause starting a tmux server doesn’t have any problem at all but for some strange reason applying this layout with a key bind breaks PATH and makes my binary undiscoverable.