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)
This commit is contained in:
@@ -1,49 +0,0 @@
|
||||
{ config, pkgs, ... }:
|
||||
|
||||
{
|
||||
environment.systemPackages = with pkgs; [
|
||||
# ── 核心工具 ──
|
||||
curl
|
||||
git
|
||||
micro
|
||||
vim
|
||||
wget
|
||||
|
||||
# ── 现代 CLI 替代 ──
|
||||
bat # cat
|
||||
btop # top
|
||||
duf # df
|
||||
dust # du
|
||||
eza # ls
|
||||
fd # find
|
||||
jq # JSON
|
||||
procs # ps
|
||||
ripgrep # grep
|
||||
sd # sed
|
||||
xh # curl/httpie
|
||||
yq # YAML
|
||||
|
||||
# ── 文件管理 ──
|
||||
trash-cli
|
||||
yazi
|
||||
|
||||
# ── 系统信息 ──
|
||||
fastfetch
|
||||
tealdeer # tldr
|
||||
];
|
||||
|
||||
# ── Nix 设置 ──
|
||||
nix.settings = {
|
||||
experimental-features = [
|
||||
"nix-command"
|
||||
"flakes"
|
||||
];
|
||||
# 国内镜像(按需取消注释)
|
||||
# substituters = [
|
||||
# "https://mirrors.tuna.tsinghua.edu.cn/nix-channels/store"
|
||||
# "https://cache.nixos.org"
|
||||
# ];
|
||||
};
|
||||
|
||||
nixpkgs.config.allowUnfree = true;
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
{ pkgs, username, ... }:
|
||||
|
||||
{
|
||||
# ── Shell ──────────────────────────────────────────
|
||||
programs.zsh.enable = true;
|
||||
|
||||
# ── User ───────────────────────────────────────────
|
||||
users.users.${username} = {
|
||||
home = "/Users/${username}";
|
||||
shell = pkgs.zsh;
|
||||
};
|
||||
|
||||
# ── Fonts ──────────────────────────────────────────
|
||||
fonts.packages = with pkgs; [
|
||||
maple-mono.NF-CN-unhinted
|
||||
nerd-fonts.symbols-only
|
||||
];
|
||||
|
||||
# ── macOS system preferences ───────────────────────
|
||||
system.defaults = {
|
||||
dock = {
|
||||
autohide = true;
|
||||
show-recents = false;
|
||||
mru-spaces = false;
|
||||
};
|
||||
finder = {
|
||||
AppleShowAllExtensions = true;
|
||||
FXPreferredViewStyle = "clmv";
|
||||
};
|
||||
NSGlobalDomain = {
|
||||
AppleShowAllExtensions = true;
|
||||
InitialKeyRepeat = 15;
|
||||
KeyRepeat = 2;
|
||||
};
|
||||
};
|
||||
|
||||
# ── Homebrew (GUI apps not in nixpkgs) ─────────────
|
||||
# homebrew = {
|
||||
# enable = true;
|
||||
# casks = [
|
||||
# "raycast"
|
||||
# "arc"
|
||||
# ];
|
||||
# onActivation.cleanup = "zap";
|
||||
# };
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
{ config, pkgs, ... }:
|
||||
|
||||
{
|
||||
environment.systemPackages = with pkgs; [
|
||||
# ── 语言运行时 ──
|
||||
bun
|
||||
go
|
||||
nodejs
|
||||
|
||||
# ── 包管理 / 版本管理 ──
|
||||
mise
|
||||
uv
|
||||
|
||||
# ── 编辑器 ──
|
||||
neovim
|
||||
|
||||
# ── 终端复用 ──
|
||||
tmux
|
||||
zellij
|
||||
|
||||
# ── Git 增强 ──
|
||||
delta # Arch 包名: git-delta
|
||||
gh # Arch 包名: github-cli
|
||||
lazygit
|
||||
|
||||
# ── Linter / Formatter ──
|
||||
biome
|
||||
ruff
|
||||
shellcheck
|
||||
shfmt
|
||||
|
||||
# ── LSP 服务器 ──
|
||||
ast-grep
|
||||
bash-language-server
|
||||
gopls
|
||||
typescript-language-server # 若报错尝试 nodePackages.typescript-language-server
|
||||
yaml-language-server # 若报错尝试 nodePackages.yaml-language-server
|
||||
vue-language-server # 替代原 bun -g @vue/language-server
|
||||
dockerfile-language-server-nodejs # 替代原 bun -g dockerfile-language-server
|
||||
|
||||
# ── 原 bun/go 全局安装的工具 ──
|
||||
# 以下工具如果在 nixpkgs 中不存在,需要自定义打包:
|
||||
#
|
||||
# opencode-ai:
|
||||
# buildNpmPackage { pname = "opencode-ai"; ... }
|
||||
#
|
||||
# go-claude-code-comment-checker:
|
||||
# buildGoModule {
|
||||
# pname = "comment-checker";
|
||||
# src = fetchFromGitHub { owner = "code-yeongyu"; repo = "..."; ... };
|
||||
# vendorHash = "sha256-...";
|
||||
# }
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
{ pkgs, ... }:
|
||||
|
||||
{
|
||||
# ── System-essential packages ──────────────────────
|
||||
# User-level tools live in home-manager (home/)
|
||||
environment.systemPackages = with pkgs; [
|
||||
curl
|
||||
git
|
||||
vim
|
||||
wget
|
||||
];
|
||||
|
||||
# ── Fonts ──────────────────────────────────────────
|
||||
fonts.packages = with pkgs; [
|
||||
maple-mono.NF-CN-unhinted
|
||||
nerd-fonts.symbols-only
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
{ pkgs, username, ... }:
|
||||
|
||||
{
|
||||
imports = [
|
||||
./base.nix
|
||||
./docker.nix
|
||||
./locale.nix
|
||||
];
|
||||
|
||||
# ── Default shell ──────────────────────────────────
|
||||
programs.zsh.enable = true;
|
||||
|
||||
# ── Default user ───────────────────────────────────
|
||||
users.users.${username} = {
|
||||
isNormalUser = true;
|
||||
shell = pkgs.zsh;
|
||||
extraGroups = [ "wheel" ];
|
||||
};
|
||||
|
||||
# ── sudo ───────────────────────────────────────────
|
||||
security.sudo.wheelNeedsPassword = false;
|
||||
}
|
||||
@@ -1,16 +1,14 @@
|
||||
{ config, pkgs, ... }:
|
||||
{ pkgs, username, ... }:
|
||||
|
||||
{
|
||||
virtualisation.docker = {
|
||||
enable = true;
|
||||
};
|
||||
virtualisation.docker.enable = true;
|
||||
|
||||
users.users.${username}.extraGroups = [ "docker" ];
|
||||
|
||||
environment.systemPackages = with pkgs; [
|
||||
docker-compose
|
||||
];
|
||||
|
||||
# 注:用户 docker 组权限在 hosts/*/default.nix 中配置
|
||||
#
|
||||
# WSL 环境下如使用 Docker Desktop,可改为:
|
||||
# wsl.docker-desktop.enable = true;
|
||||
# 并将上面的 virtualisation.docker.enable 设为 false
|
||||
@@ -1,8 +1,10 @@
|
||||
{ config, ... }:
|
||||
{ ... }:
|
||||
|
||||
{
|
||||
i18n = {
|
||||
defaultLocale = "en_US.UTF-8";
|
||||
supportedLocales = [ "en_US.UTF-8/UTF-8" ];
|
||||
};
|
||||
|
||||
time.timeZone = "Asia/Shanghai";
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
imports = [ ./nix.nix ];
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
{ lib, ... }:
|
||||
|
||||
{
|
||||
nix.settings = {
|
||||
experimental-features = [
|
||||
"nix-command"
|
||||
"flakes"
|
||||
];
|
||||
warn-dirty = false;
|
||||
# 国内镜像(按需取消注释)
|
||||
# substituters = [
|
||||
# "https://mirrors.tuna.tsinghua.edu.cn/nix-channels/store"
|
||||
# "https://cache.nixos.org"
|
||||
# ];
|
||||
};
|
||||
|
||||
nixpkgs.config.allowUnfree = true;
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
{ config, pkgs, ... }:
|
||||
|
||||
{
|
||||
# 系统级启用 Zsh(用户级配置在 home/shell.nix)
|
||||
programs.zsh.enable = true;
|
||||
}
|
||||
Reference in New Issue
Block a user