mirror of
https://github.com/ryan4yin/nix-config.git
synced 2026-04-27 19:27:05 +02:00
feat: add develop environment for ruby
This commit is contained in:
3
home/base/gui/default.nix
Normal file
3
home/base/gui/default.nix
Normal file
@@ -0,0 +1,3 @@
|
||||
{mylib, ...}: {
|
||||
imports = mylib.scanPaths ./.;
|
||||
}
|
||||
14
home/base/gui/dev-tools.nix
Normal file
14
home/base/gui/dev-tools.nix
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
pkgs,
|
||||
...
|
||||
}: {
|
||||
home.packages = with pkgs; [
|
||||
# db related
|
||||
dbeaver
|
||||
|
||||
mitmproxy # http/https proxy tool
|
||||
insomnia # REST client
|
||||
wireshark # network analyzer
|
||||
ventoy # create bootable usb
|
||||
];
|
||||
}
|
||||
16
home/base/gui/media.nix
Normal file
16
home/base/gui/media.nix
Normal file
@@ -0,0 +1,16 @@
|
||||
{
|
||||
pkgs,
|
||||
config,
|
||||
...
|
||||
}:
|
||||
# processing audio/video
|
||||
{
|
||||
home.packages = with pkgs; [
|
||||
ffmpeg-full
|
||||
|
||||
# images
|
||||
viu # Terminal image viewer with native support for iTerm and Kitty
|
||||
imagemagick
|
||||
graphviz
|
||||
];
|
||||
}
|
||||
73
home/base/gui/terminal/README.md
Normal file
73
home/base/gui/terminal/README.md
Normal file
@@ -0,0 +1,73 @@
|
||||
# Termianl Emulators
|
||||
|
||||
I used to spend a lot of time on terminal emulators, to make them match my taste,
|
||||
but now I found that it's not worth it, **Zellij can provide a user-friendly and unified user experience for all terminal emulators! without any pain**!
|
||||
|
||||
Currently, I only use the most basic features of terminal emulators, such as true color, graphics protocol, etc.
|
||||
Other features such as tabs, scrollback buffer, select/search/copy, etc, are all provided by zellij!
|
||||
|
||||
My current terminal emulators are:
|
||||
|
||||
1. kitty: My main terminal emulator.
|
||||
1. to select/copy a large mount of text, We should do some tricks via kitty's `scrollback_pager` with neovim, it's really painful: <https://github.com/kovidgoyal/kitty/issues/719>
|
||||
2. wezterm: My secondary terminal emulator.
|
||||
1. its search ability is very basic, and it's not easy to use.
|
||||
1. its scrollback buffer's copy mode is very like vim, which is nice, but zellij's even better, it can use neovim as its default scrollback buffer's editor without any pain!
|
||||
3. foot: a fast, lightweight and minimalistic Wayland terminal emulator.
|
||||
1. foot only do the things a terminal emulator should do, no more, no less.
|
||||
1. It's really suitable for tiling window manager or zellij users!
|
||||
|
||||
## '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
|
||||
|
||||
> https://wezfurlong.org/wezterm/config/lua/config/term.html
|
||||
|
||||
kitty set `TERM` to `xterm-kitty` by default, and TUI apps like `viu`, `yazi`, `curses` will try to search in the host's [terminfo(terminal capability data base)](https://linux.die.net/man/5/terminfo) for value of `TERM` to determine the capabilities of the terminal.
|
||||
|
||||
But when you `ssh` into a remote host, the remote host is very likely to not have `xterm-kitty` in its terminfo, so you will get this error:
|
||||
|
||||
```
|
||||
'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:
|
||||
|
||||
```
|
||||
kitten ssh user@host
|
||||
```
|
||||
|
||||
Or if you do not care about kitty's features(such as true color & graphics protocol), you can simply set `TERM` to `xterm-256color`, which is built-in in most linux distributions:
|
||||
|
||||
```
|
||||
export TERM=xterm-256color
|
||||
```
|
||||
|
||||
If you need kitty's features, but do not like the magic of `kitten`, you can manually install kitty's terminfo on the remote host:
|
||||
|
||||
```bash
|
||||
# install on ubuntu / debian
|
||||
sudo apt-get install kitty-terminfo
|
||||
|
||||
# or copy from local machine
|
||||
infocmp -a xterm-kitty | ssh myserver tic -x -o \~/.terminfo /dev/stdin
|
||||
```
|
||||
|
||||
3
home/base/gui/terminal/default.nix
Normal file
3
home/base/gui/terminal/default.nix
Normal file
@@ -0,0 +1,3 @@
|
||||
{mylib, ...}: {
|
||||
imports = mylib.scanPaths ./.;
|
||||
}
|
||||
53
home/base/gui/terminal/kitty.nix
Normal file
53
home/base/gui/terminal/kitty.nix
Normal file
@@ -0,0 +1,53 @@
|
||||
{
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
###########################################################
|
||||
#
|
||||
# Kitty Configuration
|
||||
#
|
||||
# Useful Hot Keys for Linux(replace `ctrl + shift` with `cmd` on macOS)):
|
||||
# 1. Increase Font Size: `ctrl + shift + =` | `ctrl + shift + +`
|
||||
# 2. Decrease Font Size: `ctrl + shift + -` | `ctrl + shift + _`
|
||||
# 3. And Other common shortcuts such as Copy, Paste, Cursor Move, etc.
|
||||
#
|
||||
###########################################################
|
||||
{
|
||||
programs.kitty = {
|
||||
enable = true;
|
||||
# kitty has catppuccin theme built-in,
|
||||
# all the built-in themes are packaged into an extra package named `kitty-themes`
|
||||
# and it's installed by home-manager if `theme` is specified.
|
||||
theme = "Catppuccin-Mocha";
|
||||
font = {
|
||||
name = "JetBrainsMono Nerd Font";
|
||||
# use different font size on macOS
|
||||
size =
|
||||
if pkgs.stdenv.isDarwin
|
||||
then 14
|
||||
else 13;
|
||||
};
|
||||
|
||||
# consistent with wezterm
|
||||
keybindings = {
|
||||
"ctrl+shift+m" = "toggle_maximized";
|
||||
"ctrl+shift+f" = "show_scrollback"; # search in the current window
|
||||
};
|
||||
|
||||
settings = {
|
||||
background_opacity = "0.93";
|
||||
macos_option_as_alt = true; # Option key acts as Alt on macOS
|
||||
enable_audio_bell = false;
|
||||
tab_bar_edge = "top"; # tab bar on top
|
||||
# To resolve issues:
|
||||
# 1. https://github.com/ryan4yin/nix-config/issues/26
|
||||
# 2. https://github.com/ryan4yin/nix-config/issues/8
|
||||
# Spawn a nushell in login mode via `bash`
|
||||
shell = "${pkgs.bash}/bin/bash --login -c 'nu --login --interactive'";
|
||||
};
|
||||
|
||||
# macOS specific settings
|
||||
darwinLaunchOptions = ["--start-as=maximized"];
|
||||
};
|
||||
}
|
||||
105
home/base/gui/terminal/wezterm.nix
Normal file
105
home/base/gui/terminal/wezterm.nix
Normal file
@@ -0,0 +1,105 @@
|
||||
{pkgs, ...}:
|
||||
###########################################################
|
||||
#
|
||||
# Wezterm Configuration
|
||||
#
|
||||
# Useful Hot Keys for Linux(replace `ctrl + shift` with `cmd` on macOS)):
|
||||
# 1. Increase Font Size: `ctrl + shift + =` | `ctrl + shift + +`
|
||||
# 2. Decrease Font Size: `ctrl + shift + -` | `ctrl + shift + _`
|
||||
# 3. And Other common shortcuts such as Copy, Paste, Cursor Move, etc.
|
||||
#
|
||||
# Default Keybindings: https://wezfurlong.org/wezterm/config/default-keys.html
|
||||
#
|
||||
###########################################################
|
||||
{
|
||||
# wezterm has catppuccin theme built-in,
|
||||
# it's not necessary to install it separately.
|
||||
|
||||
# we can add wezterm as a flake input once this PR is merged:
|
||||
# https://github.com/wez/wezterm/pull/3547
|
||||
|
||||
programs.wezterm = {
|
||||
enable = true; # disable
|
||||
|
||||
# install wezterm via homebrew on macOS to avoid compilation, dummy package here.
|
||||
package =
|
||||
if pkgs.stdenv.isLinux
|
||||
then pkgs.wezterm
|
||||
else pkgs.hello;
|
||||
|
||||
enableBashIntegration = pkgs.stdenv.isLinux;
|
||||
enableZshIntegration = pkgs.stdenv.isLinux;
|
||||
|
||||
extraConfig = let
|
||||
fontsize =
|
||||
if pkgs.stdenv.isLinux
|
||||
then "13.0"
|
||||
else "14.0";
|
||||
in ''
|
||||
-- Pull in the wezterm API
|
||||
local wezterm = require 'wezterm'
|
||||
|
||||
-- This table will hold the configuration.
|
||||
local config = {}
|
||||
|
||||
-- In newer versions of wezterm, use the config_builder which will
|
||||
-- help provide clearer error messages
|
||||
if wezterm.config_builder then
|
||||
config = wezterm.config_builder()
|
||||
end
|
||||
|
||||
wezterm.on('toggle-opacity', function(window, pane)
|
||||
local overrides = window:get_config_overrides() or {}
|
||||
if not overrides.window_background_opacity then
|
||||
overrides.window_background_opacity = 0.93
|
||||
else
|
||||
overrides.window_background_opacity = nil
|
||||
end
|
||||
window:set_config_overrides(overrides)
|
||||
end)
|
||||
|
||||
wezterm.on('toggle-maximize', function(window, pane)
|
||||
window:maximize()
|
||||
end)
|
||||
|
||||
-- This is where you actually apply your config choices
|
||||
config.color_scheme = "Catppuccin Mocha"
|
||||
config.font = wezterm.font_with_fallback {
|
||||
"JetBrainsMono Nerd Font",
|
||||
"FiraCode Nerd Font",
|
||||
|
||||
-- To avoid 'Chinese characters displayed as variant (Japanese) glyphs'
|
||||
"Source Han Sans SC",
|
||||
"Source Han Sans TC"
|
||||
}
|
||||
|
||||
config.hide_tab_bar_if_only_one_tab = true
|
||||
config.scrollback_lines = 10000
|
||||
config.enable_scroll_bar = true
|
||||
config.term = 'wezterm'
|
||||
|
||||
config.keys = {
|
||||
-- toggle opacity(CTRL + SHIFT + B)
|
||||
{
|
||||
key = 'B',
|
||||
mods = 'CTRL',
|
||||
action = wezterm.action.EmitEvent 'toggle-opacity',
|
||||
},
|
||||
{
|
||||
key = 'M',
|
||||
mods = 'CTRL',
|
||||
action = wezterm.action.EmitEvent 'toggle-maximize',
|
||||
},
|
||||
}
|
||||
config.font_size = ${fontsize}
|
||||
|
||||
-- To resolve issues:
|
||||
-- 1. https://github.com/ryan4yin/nix-config/issues/26
|
||||
-- 2. https://github.com/ryan4yin/nix-config/issues/8
|
||||
-- Spawn a nushell in login mode via `bash`
|
||||
config.default_prog = { '${pkgs.bash}/bin/bash', '--login', '-c', 'nu --login --interactive' }
|
||||
|
||||
return config
|
||||
'';
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user