Files
nix-config/scripts/install.sh
T
imbytecat e92c7aee31 refactor: 重构为多平台多用户架构,全面提升终端体验
- 新增 lib/ 辅助函数(mkNixos/mkDarwin/mkHome),消除硬编码
- 拆分 modules/ 为 nixos/darwin/shared 三层,支持跨平台共享
- 重构 home/ 为 shell/dev/theme 子模块,工具全部迁入用户级
- 深度配置 Tmux/FZF/Atuin/Bat/Eza/Btop/Lazygit/Starship
- 添加 Catppuccin Mocha 统一主题、Nerd Fonts 声明式管理
- 新增 homeConfigurations 输出,支持非 NixOS 系统直装
- 新增 nix-darwin 输入,预留 macOS 扩展路径
- 新增 overlays/ 和 pkgs/ 自定义包基础设施
- 修正 nix-darwin URL(LnL7 → nix-darwin org)
2026-04-03 19:54:17 +08:00

52 lines
1.7 KiB
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/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"
;;
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
;;
esac