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,5 +1,5 @@
|
||||
{
|
||||
description = "NixOS 声明式系统配置";
|
||||
description = "Multi-platform Nix configuration — NixOS / nix-darwin / standalone Home Manager";
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||
@@ -13,47 +13,67 @@
|
||||
url = "github:nix-community/home-manager";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
|
||||
nix-darwin = {
|
||||
url = "github:nix-darwin/nix-darwin";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
|
||||
catppuccin = {
|
||||
url = "github:catppuccin/nix";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
};
|
||||
|
||||
outputs =
|
||||
{
|
||||
self,
|
||||
nixpkgs,
|
||||
nixos-wsl,
|
||||
home-manager,
|
||||
...
|
||||
}:
|
||||
}@inputs:
|
||||
let
|
||||
system = "x86_64-linux";
|
||||
|
||||
# 所有主机共享的模块
|
||||
commonModules = [
|
||||
./modules/base.nix
|
||||
./modules/dev.nix
|
||||
./modules/docker.nix
|
||||
./modules/locale.nix
|
||||
./modules/shell.nix
|
||||
home-manager.nixosModules.home-manager
|
||||
];
|
||||
mylib = import ./lib { inherit inputs; };
|
||||
in
|
||||
{
|
||||
# ── NixOS hosts ────────────────────────────────────
|
||||
nixosConfigurations = {
|
||||
# WSL 配置
|
||||
wsl = nixpkgs.lib.nixosSystem {
|
||||
inherit system;
|
||||
modules = commonModules ++ [
|
||||
nixos-wsl.nixosModules.default
|
||||
./hosts/wsl/default.nix
|
||||
wsl = mylib.mkNixos {
|
||||
hostname = "nixos-wsl";
|
||||
system = "x86_64-linux";
|
||||
username = "dev";
|
||||
extraModules = [
|
||||
inputs.nixos-wsl.nixosModules.default
|
||||
./hosts/wsl
|
||||
];
|
||||
};
|
||||
|
||||
# 裸机配置
|
||||
bare = nixpkgs.lib.nixosSystem {
|
||||
inherit system;
|
||||
modules = commonModules ++ [
|
||||
./hosts/bare/default.nix
|
||||
];
|
||||
bare = mylib.mkNixos {
|
||||
hostname = "nixos";
|
||||
system = "x86_64-linux";
|
||||
username = "dev";
|
||||
extraModules = [ ./hosts/bare ];
|
||||
};
|
||||
};
|
||||
|
||||
# ── macOS hosts (uncomment when ready) ─────────────
|
||||
# darwinConfigurations = {
|
||||
# macbook = mylib.mkDarwin {
|
||||
# hostname = "macbook";
|
||||
# system = "aarch64-darwin";
|
||||
# username = "imbytecat";
|
||||
# extraModules = [ ./hosts/macbook ];
|
||||
# };
|
||||
# };
|
||||
|
||||
# ── Standalone Home Manager (non-NixOS / non-Darwin) ─
|
||||
homeConfigurations = {
|
||||
"dev" = mylib.mkHome {
|
||||
system = "x86_64-linux";
|
||||
username = "dev";
|
||||
};
|
||||
};
|
||||
|
||||
# ── Overlays ───────────────────────────────────────
|
||||
overlays.default = import ./overlays;
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user