mirror of
https://github.com/ryan4yin/nix-config.git
synced 2026-03-30 14:21:51 +02:00
fix: terminfo error on macOS
This commit is contained in:
3
Makefile
3
Makefile
@@ -47,7 +47,8 @@ gc:
|
||||
############################################################################
|
||||
|
||||
darwin-set-proxy:
|
||||
sudo python3 scripts/darwin_set_proxy.py
|
||||
echo "skip setting proxy, use global proxy instead"
|
||||
# sudo python3 scripts/darwin_set_proxy.py
|
||||
|
||||
ha: darwin-set-proxy
|
||||
nix build .#darwinConfigurations.harmonica.system
|
||||
|
||||
@@ -416,12 +416,13 @@
|
||||
# status: https://mirrors.ustc.edu.cn/status/
|
||||
# "https://mirrors.ustc.edu.cn/nix-channels/store"
|
||||
|
||||
# my own cache server
|
||||
# fallback to official cache server if the above mirrors are not available
|
||||
"https://cache.nixos.org"
|
||||
|
||||
# fallback to other non-official cache server
|
||||
"https://ryan4yin.cachix.org"
|
||||
"https://anyrun.cachix.org"
|
||||
"https://hyprland.cachix.org"
|
||||
|
||||
"https://cache.nixos.org"
|
||||
];
|
||||
|
||||
# nix community's cache server
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
3. alacritty: Standby terminal.
|
||||
|
||||
|
||||
## 'xterm-kitty': unknown terminal type when `ssh` into a remote host
|
||||
## 'xterm-kitty': unknown terminal type when `ssh` into a remote host or `sudo xxx`
|
||||
|
||||
> https://sw.kovidgoyal.net/kitty/faq/#i-get-errors-about-the-terminal-being-unknown-or-opening-the-terminal-failing-or-functional-keys-like-arrow-keys-don-t-work
|
||||
|
||||
@@ -19,6 +19,22 @@ But when you `ssh` into a remote host, the remote host is very likely to not hav
|
||||
'xterm-kitty': unknown terminal type
|
||||
```
|
||||
|
||||
Or when you `sudo xxx`, `sudo` won't preserve the `TERM` variable, it will be reset to root's default `TERM` value, which is `xterm` or `xterm-256color` in most linux distributions, so you will get this error:
|
||||
|
||||
```
|
||||
'xterm-256color': unknown terminal type
|
||||
```
|
||||
|
||||
or
|
||||
|
||||
```
|
||||
Error opening terminal: xterm-kitty.
|
||||
```
|
||||
|
||||
NixOS preserve the `TERMINFO` and `TERMINFO_DIRS` environment variables, for `root` and the `wheel` group: [nixpkgs/nixos/modules/config/terminfo.nix](https://github.com/NixOS/nixpkgs/blob/nixos-23.11/nixos/modules/config/terminfo.nix#L18)
|
||||
|
||||
For nix-darwin, take a look at <https://github.com/LnL7/nix-darwin/wiki/Terminfo-issues>
|
||||
|
||||
### Solutions
|
||||
|
||||
Simplest solution, it will automatically copy over the terminfo files and also magically enable shell integration on the remote machine:
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{pkgs, ...}: {
|
||||
{pkgs, config, ...}: {
|
||||
##########################################################################
|
||||
#
|
||||
# Install all apps and packages here.
|
||||
@@ -23,7 +23,12 @@
|
||||
gnugrep # replacee macos's grep
|
||||
gnutar # replacee macos's tar
|
||||
];
|
||||
environment.variables.EDITOR = "nvim";
|
||||
environment.variables = {
|
||||
# Fix https://github.com/LnL7/nix-darwin/wiki/Terminfo-issues
|
||||
# TERMINFO_DIRS = map (path: path + "/share/terminfo") config.environment.profiles ++ [ "/usr/share/terminfo" ];
|
||||
|
||||
EDITOR = "nvim";
|
||||
};
|
||||
|
||||
# Create /etc/zshrc that loads the nix-darwin environment.
|
||||
# this is required if you want to use darwin's default shell - zsh
|
||||
|
||||
@@ -43,6 +43,9 @@
|
||||
};
|
||||
users.users.root.initialHashedPassword = "$7$CU..../....X6uvZYnFD.i1CqqFFNl4./$4vgqzIPyw5XBr0aCDFbY/UIRRJr7h5SMGoQ/ZvX3FP2";
|
||||
|
||||
# fix for `sudo xxx` in kitty/wezterm and other modern terminal emulators
|
||||
security.sudo.keepTerminfo = true;
|
||||
|
||||
# DO NOT promote the specified user to input password for `nix-store` and `nix-copy-closure`
|
||||
security.sudo.extraRules = [
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user