Files
nix-config/home/base/tui/tuios/default.nix
T
ryan4yin | 二花 d8b298019a refactor(shells): use native Home Manager Nushell and Nushell login on non-desktop hosts (#513)
* refactor(shells): use native Home Manager Nushell environment

Replace the Bash login-shell wrapper and hand-maintained Nushell PATH with programs.nushell.loadSessionVariables and home.sessionPath. Launch Nushell directly from Kitty, Ghostty, and Zed, with the macOS config-home override and Ghostty's vendor autoload directory.

Upstream feature: https://github.com/nix-community/home-manager/pull/9666

Assisted-by: DeepSeek Harness (deepseek-flash)

* feat(hosts): use Nushell as login shell on Ruby and Kana

Set the per-user shell explicitly and add Nushell to the system shell list. The system default shell and root remain unchanged.

Assisted-by: DeepSeek Harness (deepseek-flash)

* fix(ssh): preserve tuios session marker across SSH

Forward TUIOS_SESSION and accept it on NixOS sshd, so an SSH session opened from inside tuios does not auto-attach a nested remote tuios.

Assisted-by: DeepSeek Harness (deepseek-flash)

* feat(nixos): use Nushell login shell on non-desktop hosts

Enable the Nushell login shell through a shared module imported by the server and agent profiles. Desktop profiles continue to use Bash.

Assisted-by: DeepSeek Harness (deepseek-flash)

* fix(tuios): skip auto-attach in SSH sessions

Remote interactive shells now stay plain Nushell instead of starting a nested TUIOS when the SSH client is already inside a local TUIOS session. Local TUIOS auto-start is unchanged.

Assisted-by: DeepSeek Harness (deepseek-flash)
2026-11-03 22:31:24 +08:00

53 lines
1.9 KiB
Nix

{
config,
pkgs,
...
}:
let
# tuios watches config.toml and its settings page writes it back, so link the
# checked-in file out-of-store instead of into the store.
configDir = "${config.home.homeDirectory}/nix-config/home/base/tui/tuios";
in
{
home.packages = [ pkgs.tuios ];
xdg.configFile."tuios/config.toml".source =
config.lib.file.mkOutOfStoreSymlink "${configDir}/config.toml";
# auto-start tuios in local interactive shells, except when already inside
# tuios or connected over SSH.
# `work` for the ~/work tree, `personal` for everything else (a host with no
# ~/work gets `personal` everywhere).
programs.nushell.extraConfig = ''
# TUIOS keeps TERM=xterm-256color for terminfo compatibility, even though
# this host's only terminal emulators (kitty and Ghostty) both speak the
# Kitty graphics protocol and TUIOS forwards it. Force the guest TERM to
# xterm-kitty so graphics-aware apps do not disable themselves; its
# terminfo entry comes with kitty.
if ("TUIOS_ENV" in $env) {
$env.TERM = "xterm-kitty"
}
if $nu.is-interactive and (not ("TUIOS_SESSION" in $env)) and (not ("SSH_CONNECTION" in $env)) {
# Exit 3 means the daemon is stopped; stdout still lists saved sessions.
let listing = (^tuios ls --json | complete)
if $listing.exit_code not-in [0 3] {
error make {msg: $"tuios ls failed: ($listing.stderr)"}
}
let sessions = ($listing.stdout | from json | get name)
let work_root = ($nu.home-dir | path join "work")
if $env.PWD == $work_root or ($env.PWD | str starts-with $"($work_root)/") {
if "work" not-in $sessions {
^tuios new work --detach --cwd $work_root
}
^tuios attach work
} else {
if "personal" not-in $sessions {
^tuios new personal --detach --cwd $nu.home-dir
}
^tuios attach personal
}
}
'';
}