feat: NixOS 声明式配置(从 Arch + decman 迁移)

- flake.nix: NixOS + home-manager + nixos-wsl 三输入
- hosts/wsl + hosts/bare: WSL 与裸机共享模块,分主机配置
- modules/: base(CLI 工具) + dev(工具链+LSP) + docker + locale + shell
- home/: zsh(oh-my-zsh+插件+别名) + git(delta) + starship + 工具集成
- scripts/install.sh: 一键安装脚本(WSL/裸机通用)
- 原 bun/go 全局包 hack 改为 nixpkgs 声明式管理
This commit is contained in:
2026-04-03 19:05:06 +08:00
parent 5c851ea250
commit d58c650d59
33 changed files with 574 additions and 1058 deletions
-22
View File
@@ -1,22 +0,0 @@
[http "https://202.127.0.42:32443"]
sslVerify = false
[core]
pager = delta
[interactive]
diffFilter = delta --color-only
[delta]
navigate = true
side-by-side = true
line-numbers = true
[credential]
helper = store
[merge]
conflictstyle = zdiff3
[pull]
rebase = true
[push]
autoSetupRemote = true
[init]
defaultBranch = main
[rerere]
enabled = true
-2
View File
@@ -1,2 +0,0 @@
[settings]
trusted_config_paths = ["/"]
-41
View File
@@ -1,41 +0,0 @@
format = """
$username\
$hostname\
$directory\
$git_branch\
$git_status\
$nodejs\
$python\
$go\
$rust\
$cmd_duration\
$line_break\
$character"""
[character]
success_symbol = "[](bold green)"
error_symbol = "[](bold red)"
[directory]
truncation_length = 3
truncation_symbol = "…/"
[git_branch]
symbol = " "
[git_status]
format = '([\[$all_status$ahead_behind\]]($style) )'
[cmd_duration]
min_time = 2000
format = "[$duration]($style) "
[nodejs]
format = "[$symbol($version)]($style) "
detect_extensions = []
[python]
format = "[$symbol($version)]($style) "
[go]
format = "[$symbol($version)]($style) "
-63
View File
@@ -1,63 +0,0 @@
# ── PATH ──
export PATH="$HOME/go/bin:$HOME/.bun/bin:$PATH"
# ── Shell 选项 ──
setopt AUTO_CD # 输目录名直接 cd
setopt INTERACTIVE_COMMENTS # 允许交互式 # 注释
setopt NO_BEEP # 关蜂鸣
# ── Oh My Zsh ──
ZSH=/usr/share/oh-my-zsh/
ZSH_THEME="" # Starship 接管提示符
plugins=(
git # git 别名(gst, gco, gp...
sudo # 双击 ESC 自动加 sudo
extract # x file.tar.gz 一键解压任何格式
direnv # direnv hook
)
ZSH_CACHE_DIR=$HOME/.cache/oh-my-zsh
[[ ! -d $ZSH_CACHE_DIR ]] && mkdir -p $ZSH_CACHE_DIR
source $ZSH/oh-my-zsh.sh
# ── 外部插件 ──
source /usr/share/zsh/plugins/fzf-tab-git/fzf-tab.plugin.zsh
source /usr/share/zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh
source /usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh # 必须最后
# ── 工具初始化(顺序重要)──
eval "$(starship init zsh)"
eval "$(zoxide init zsh)"
eval "$(mise activate zsh)"
eval "$(fzf --zsh)" # Ctrl+T 搜文件, Alt+C 搜目录
eval "$(atuin init zsh)" # 必须在 fzf 之后,接管 Ctrl+R
# ── 别名 ──
# 导航
alias cd="z"
alias cdi="zi"
alias ..="cd .."
alias ...="cd ../.."
# 文件列表
alias ls="eza --icons --group-directories-first"
alias ll="eza -la --icons --git --group-directories-first"
alias la="eza -a --icons --group-directories-first"
alias lt="eza --tree --level=2 --icons"
# 工具
alias cat="bat --paging=never"
alias rm="trash-put"
alias lg="lazygit"
alias vi="nvim"
# 网络
alias http="xh"
# ── WSL 剪贴板 ──
if [[ -n "$WSL_DISTRO_NAME" ]]; then
alias pbcopy="clip.exe"
alias pbpaste="powershell.exe -noprofile -c Get-Clipboard"
fi
# ── Local ──
[[ -f ~/.zshrc.local ]] && source ~/.zshrc.local
+16
View File
@@ -0,0 +1,16 @@
{ config, pkgs, ... }:
{
imports = [
./shell.nix
./git.nix
];
home.stateVersion = "24.11";
# ── mise 配置 ──
xdg.configFile."mise/config.toml".text = ''
[settings]
trusted_config_paths = ["/"]
'';
}
+36
View File
@@ -0,0 +1,36 @@
{ config, ... }:
{
programs.git = {
enable = true;
# user.name 和 user.email 需要每人自行设置:
# git config --global user.name "你的名字"
# git config --global user.email "你的邮箱"
delta = {
enable = true;
options = {
navigate = true;
side-by-side = true;
line-numbers = true;
};
};
extraConfig = {
# 内部 Git 服务器(跳过 SSL 验证)
http = {
"https://202.127.0.42:32443" = {
sslVerify = false;
};
};
credential.helper = "store";
merge.conflictstyle = "zdiff3";
pull.rebase = true;
push.autoSetupRemote = true;
init.defaultBranch = "main";
rerere.enabled = true;
};
};
}
+137
View File
@@ -0,0 +1,137 @@
{ config, pkgs, ... }:
{
# ── Zsh ──────────────────────────────────────────────
programs.zsh = {
enable = true;
autocd = true; # setopt AUTO_CD
oh-my-zsh = {
enable = true;
plugins = [
"git" # git 别名 (gst, gco, gp...)
"sudo" # 双击 ESC 自动加 sudo
"extract" # x file.tar.gz 一键解压
"direnv" # direnv hook
];
};
autosuggestion.enable = true;
syntaxHighlighting.enable = true;
shellAliases = {
# 导航
cd = "z";
cdi = "zi";
".." = "cd ..";
"..." = "cd ../..";
# 文件列表
ls = "eza --icons --group-directories-first";
ll = "eza -la --icons --git --group-directories-first";
la = "eza -a --icons --group-directories-first";
lt = "eza --tree --level=2 --icons";
# 工具
cat = "bat --paging=never";
rm = "trash-put";
lg = "lazygit";
vi = "nvim";
# 网络
http = "xh";
};
initExtra = ''
# Shell
setopt INTERACTIVE_COMMENTS
setopt NO_BEEP
# PATH go/bun
export PATH="$HOME/go/bin:$HOME/.bun/bin:$PATH"
# fzf-tab
# : ls $(nix eval --raw nixpkgs#zsh-fzf-tab)/share/
source ${pkgs.zsh-fzf-tab}/share/fzf-tab/fzf-tab.plugin.zsh
# mise
eval "$(mise activate zsh)"
# WSL
if [[ -n "$WSL_DISTRO_NAME" ]]; then
alias pbcopy="clip.exe"
alias pbpaste="powershell.exe -noprofile -c Get-Clipboard"
fi
#
[[ -f ~/.zshrc.local ]] && source ~/.zshrc.local
'';
};
# ── Starship 提示符 ──────────────────────────────────
programs.starship = {
enable = true;
enableZshIntegration = true;
settings = {
format = "$username$hostname$directory$git_branch$git_status$nodejs$python$go$rust$cmd_duration$line_break$character";
character = {
success_symbol = "[](bold green)";
error_symbol = "[](bold red)";
};
directory = {
truncation_length = 3;
truncation_symbol = "/";
};
git_branch.symbol = " ";
git_status.format = "([\\[$all_status$ahead_behind\\]]($style) )";
cmd_duration = {
min_time = 2000;
format = "[$duration]($style) ";
};
nodejs = {
format = "[$symbol($version)]($style) ";
detect_extensions = [ ];
};
python.format = "[$symbol($version)]($style) ";
go.format = "[$symbol($version)]($style) ";
};
};
# ── FZF ──────────────────────────────────────────────
programs.fzf = {
enable = true;
enableZshIntegration = true;
};
# ── Atuin(历史搜索,接管 Ctrl+R)──────────────────
programs.atuin = {
enable = true;
enableZshIntegration = true;
};
# ── Zoxide(智能 cd)─────────────────────────────────
programs.zoxide = {
enable = true;
enableZshIntegration = true;
};
# ── Direnv ───────────────────────────────────────────
programs.direnv = {
enable = true;
enableZshIntegration = true;
nix-direnv.enable = true; # 更好的 Nix devShell 集成
};
# ── Bat ──────────────────────────────────────────────
programs.bat.enable = true;
# ── Yazi ─────────────────────────────────────────────
programs.yazi.enable = true;
}