Files
nixos/README.md
luochen570 575529f159 modified: README.md
modified:   modules/server/README.md
	new file:   modules/server/lxc-ssh.nix
	modified:   profiles/lxc.nix
2026-05-27 07:02:37 +08:00

114 lines
4.5 KiB
Markdown
Raw Permalink 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.
# NixOS Configuration
洛尘luochen570的 NixOS 配置仓库,采用 Flakes + home-manager + sops-nix 架构。
## 架构
```
nixos/
├── flake.nix # Flake 入口
├── lib/
│ ├── mkHost.nix # 主机生成函数
│ └── hosts.nix # 主机定义
├── profiles/ # 角色配置组合
│ ├── README.md
│ ├── desktop.nix # 桌面机
│ ├── server.nix # 服务器
│ ├── wsl.nix # WSL (Debian/Windows)
│ ├── virtualbox.nix # VirtualBox 虚拟机
│ └── lxc.nix # Proxmox LXC 容器
├── modules/ # 模块化配置
│ ├── core/ # 所有机器共享的基础配置
│ │ ├── default.nix
│ │ ├── core.nix # Nix 设置、时区、语言、GC
│ │ ├── pkg.nix # 基础系统包
│ │ ├── users.nix # 用户与 Shell
│ │ └── sops.nix # 密钥管理
│ ├── server/ # 服务器模块(默认启用)
│ │ ├── default.nix
│ │ ├── docker.nix
│ │ └── ssh.nix
│ ├── optional/ # 选装模块(按需引用)
│ │ ├── README.md
│ │ ├── virtualbox-guest.nix # VirtualBox Guest 增强
│ │ └── vscode-server.nix # VS Code Server
│ ├── desktop/ # 桌面模块
│ │ ├── default.nix
│ │ ├── pkg.nix # 桌面应用包
│ │ ├── apps.nix # MIME 与默认应用
│ │ ├── fcitx5.nix # 中文输入法
│ │ └── de/
│ │ ├── default.nix
│ │ └── kde.nix # KDE Plasma 6 + SDDM
│ └── drivers/
│ ├── nvidia.nix # NVIDIA 独显
│ └── amdgpu.nix # AMD 核显RDNA2
├── home/ # home-manager 用户配置
│ ├── README.md
│ ├── default.nix
│ ├── pkg.nix # 用户级包
│ ├── git.nix
│ ├── ssh.nix # SSH 密钥sops 挂载)
│ ├── zsh.nix # ZSH + Powerlevel10k
│ └── nvchad.nix # Neovim (NvChad)
├── hosts/ # 主机专属配置
│ ├── README.md
│ ├── desktop/ # 桌面机AMD + NVIDIA
│ ├── server/ # 服务器
│ ├── wsl/ # WSL (NixOS-WSL)
│ ├── virtualbox/ # VirtualBox 虚拟机
│ └── nixos-lxc/ # Proxmox LXC 容器
└── secrets/ # sops-nix 加密密钥(不公开)
└── users/luochen570.enc.yaml
```
## 主机列表
| 主机 | 角色 | 架构 | 说明 |
|------|------|------|------|
| `desktop` | desktop | x86_64-linux | 桌面机NVIDIA + AMD 双显卡 |
| `server` | server | x86_64-linux | 服务器 |
| `nixos-wsl` | wsl | x86_64-linux | WSL |
| `virtualbox` | virtualbox | x86_64-linux | VirtualBox 虚拟机 |
| `nixos-lxc` | lxc | x86_64-linux | Proxmox LXC 容器 |
## 使用
```bash
# 构建/切换
sudo nixos-rebuild switch --flake .#desktop
# 仅构建不切换
sudo nixos-rebuild build --flake .#server
# 更新 flake lock
nix flake update
# 垃圾回收
sudo nix-collect-garbage --delete-older-than 14d
```
## 关键特性
- **Flakes** — 可复现的 NixOS 配置
- **home-manager** — 用户级包与配置管理
- **sops-nix** — 加密存储 SSH 密钥、密码哈希等敏感信息
- **NixOS-WSL** — WSL 集成
- **KDE Plasma 6** — 桌面环境SDDM 显示管理器)
- **fcitx5 + Rime** — 中文输入法
- **Docker** — 容器运行时,自动每周清理
- **PipeWire** — 音频系统
- **Nix4NvChad** — Neovim (NvChad) 配置即代码
## 镜像源
使用 TUNA清华和 SJTU上交镜像加速 Nix 包下载,适合国内网络环境。
## 注意事项
- NVIDIA 模块的 PRIME双显卡切换方案已注释启用前需通过 `lspci` 确认 PCIe Bus ID
- LXC 容器使用 Proxmox LXC 模块,关闭了 systemd 挂载报错的服务
- `secrets/` 目录经过 sops 加密,需有对应 age key 才能解密
- 各主机目录下有各自的 `README.md`,含该主机的硬件信息与应用列表
- `modules/optional/` 下的模块为非默认启用,按需在 profile 中引用