From 96f88b3047744e5dc2c33870c2be79396760043e Mon Sep 17 00:00:00 2001 From: imbytecat Date: Fri, 10 Apr 2026 21:58:55 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E6=B8=85=E9=99=A4=20zsh=20=E6=AE=8B?= =?UTF-8?q?=E7=95=99=EF=BC=8C=E5=A3=B0=E6=98=8E=E5=BC=8F=20git=20=E8=BA=AB?= =?UTF-8?q?=E4=BB=BD=E4=B8=8E=20SSH=20config?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 移除所有 zsh 引用,补全 fish 迁移 - git.nix: 声明 userName/userEmail,删除 credential.helper store 和内网 sslVerify - 新增 programs.ssh 声明式配置(id_ed25519, addKeysToAgent) - 简化 install.sh 为 darwin/nixos 双平台 --- .vscode/extensions.json | 3 +++ home/dev/git.nix | 27 ++++++++++--------------- home/shell/fish.nix | 4 ++-- home/theme.nix | 3 +-- scripts/install.sh | 44 ++++++++--------------------------------- 5 files changed, 24 insertions(+), 57 deletions(-) create mode 100644 .vscode/extensions.json diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000..9189a4e --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,3 @@ +{ + "recommendations": ["jnoortheen.nix-ide"] +} diff --git a/home/dev/git.nix b/home/dev/git.nix index 1109e8a..58de020 100644 --- a/home/dev/git.nix +++ b/home/dev/git.nix @@ -3,10 +3,8 @@ { programs.git = { enable = true; - - # user.name / user.email: set per-user via git config or ~/.zshrc.local - # git config --global user.name "Your Name" - # git config --global user.email "your@email.com" + userName = "imbytecat"; + userEmail = "imbytecat@gmail.com"; delta = { enable = true; @@ -14,15 +12,10 @@ navigate = true; side-by-side = true; line-numbers = true; - hyperlinks = true; }; }; extraConfig = { - # Internal Git server (skip SSL verification) - http."https://202.127.0.42:32443".sslVerify = false; - - credential.helper = "store"; merge.conflictstyle = "zdiff3"; pull.rebase = true; push.autoSetupRemote = true; @@ -33,7 +26,6 @@ }; }; - # ── Lazygit ────────────────────────────────────────── programs.lazygit = { enable = true; settings = { @@ -41,19 +33,20 @@ nerdFontsVersion = "3"; showBottomLine = false; }; - git.paging = { - pager = "delta --paging=never"; - }; + git.paging.pager = "delta --paging=never"; update.method = "never"; disableStartupPopups = true; }; }; - # ── GitHub CLI ─────────────────────────────────────── programs.gh = { enable = true; - settings = { - git_protocol = "ssh"; - }; + settings.git_protocol = "ssh"; + }; + + programs.ssh = { + enable = true; + addKeysToAgent = "yes"; + matchBlocks."*".identityFile = "~/.ssh/id_ed25519"; }; } diff --git a/home/shell/fish.nix b/home/shell/fish.nix index 18e38cd..472b37d 100644 --- a/home/shell/fish.nix +++ b/home/shell/fish.nix @@ -1,4 +1,4 @@ -{ pkgs, lib, ... }: +{ ... }: { programs.fish = { @@ -38,7 +38,7 @@ # mise mise activate fish | source - # Sudo: double Escape to prepend sudo (like zsh sudo plugin) + # Sudo: double Escape to prepend sudo bind \e\e 'fish_commandline_prepend sudo' # Platform-specific rebuild command diff --git a/home/theme.nix b/home/theme.nix index b5781e3..663845e 100644 --- a/home/theme.nix +++ b/home/theme.nix @@ -4,7 +4,6 @@ catppuccin = { enable = true; flavor = "mocha"; - # Automatically themes all supported programs that are enabled: - # bat, btop, delta, fzf, lazygit, starship, tmux, zsh-syntax-highlighting, etc. + # Automatically themes: bat, btop, delta, fish, fzf, lazygit, starship, tmux, etc. }; } diff --git a/scripts/install.sh b/scripts/install.sh index aaab975..777bda6 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -1,51 +1,23 @@ #!/bin/bash -# NixOS / standalone Home Manager 安装脚本 set -euo pipefail REPO_URL="https://git.furtherverse.com/imbytecat/nix-config.git" CONFIG_DIR="$HOME/.config/nix-config" -FLAKE_TARGET="${1:-wsl}" # wsl (default), bare, or home -echo "📥 获取配置仓库..." if [[ -d "$CONFIG_DIR/.git" ]]; then - echo "⏩ 仓库已存在,拉取最新..." git -C "$CONFIG_DIR" pull else git clone "$REPO_URL" "$CONFIG_DIR" fi -echo "⚙️ 应用配置(目标: $FLAKE_TARGET)..." - -case "$FLAKE_TARGET" in - wsl|bare) - sudo nixos-rebuild switch --flake "$CONFIG_DIR#$FLAKE_TARGET" - echo "" - echo "🎉 安装完成!请重新登录以使用 zsh。" - echo "" - echo "后续更新:" - echo " cd $CONFIG_DIR && git pull && sudo nixos-rebuild switch --flake .#$FLAKE_TARGET" +case "$(uname)" in + Darwin) + TARGET="${1:?Usage: $0 }" + darwin-rebuild switch --flake "$CONFIG_DIR#$TARGET" ;; - home) - # Standalone home-manager(非 NixOS 系统:Ubuntu、Fedora、macOS 等) - HM_USER="$(whoami)" - if ! command -v home-manager &>/dev/null; then - echo "📦 首次运行 home-manager..." - nix run home-manager/master -- switch --flake "$CONFIG_DIR#$HM_USER" - else - home-manager switch --flake "$CONFIG_DIR#$HM_USER" - fi - echo "" - echo "🎉 Home Manager 配置已应用!" - echo "" - echo "后续更新:" - echo " cd $CONFIG_DIR && git pull && home-manager switch --flake .#$HM_USER" - ;; - *) - echo "❌ 未知目标: $FLAKE_TARGET" - echo "用法: $0 [wsl|bare|home]" - echo " wsl — NixOS on WSL (默认)" - echo " bare — NixOS 裸机" - echo " home — 独立 Home Manager (非 NixOS)" - exit 1 + Linux) + sudo nixos-rebuild switch --flake "$CONFIG_DIR#wsl" ;; esac + +echo "Done! Restart your shell."