Compare commits

..

21 Commits

Author SHA1 Message Date
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
luochen570
a2bd672cf7 refactor: move sudo to core, lxc SSH to profile, clean up old lxc config
- sudo (wheelNeedsPassword) → modules/core/core.nix (全局)
- LXC SSH override (PermitRootLogin, PasswordAuth) → profiles/lxc.nix
- modules/server/ssh.nix: use mkDefault so profiles can override
- Delete modules/optional/lxc.nix
- Clean up hosts/nixos-lxc/configuration.nix: remove redundant SSH/sudo/users
  (now handled by core + server + profile chain)
- Update modules/optional/README.md
2026-05-27 06:47:50 +08:00
luochen570
d9b2204f19 refactor: move optional modules to modules/optional/
- Move virtualbox-guest.nix and vscode-server.nix from modules/server/ to modules/optional/
- Create modules/optional/README.md with usage docs
- Update profiles/virtualbox.nix and profiles/wsl.nix import paths
- Update modules/server/README.md to reflect removal
- Update root README.md directory tree with optional/ entry
2026-05-26 13:15:58 +08:00
luochen570
e3644993ec fix: pass inputs as specialArg to wsl config 2026-05-26 13:03:04 +08:00
luochen570
e279b207f8 fix: add username param to wsl configuration.nix 2026-05-26 13:02:47 +08:00
luochen570
88414eb346 fix: replace invalid 'options' attr with setopt in initExtra
home-manager's programs.zsh has no 'options' attribute.
Use 'setopt correct' and 'setopt interactive_comments' inside initExtra instead.
2026-05-26 12:50:23 +08:00
luochen570
14e57c9096 fix: add missing packages for zsh aliases and plugins
- home/pkg.nix: add eza, bat, ack, fzf
- modules/core/pkg.nix: add kubectl (for OMZ kubectl plugin)
2026-05-26 12:46:55 +08:00
luochen570
4349da57ea sync: align home-manager zsh.nix with actual .zshrc
- Add envExtra: PATH, XDG_CONFIG_HOME, POWERLEVEL9K_INSTANT_PROMPT, .hermes/node/bin
- Add shell options: correct, interactive_comments
- Add initExtra: p10k instant prompt, y() function, proxy-on/off aliases
- Add missing aliases: cd -# (1-9), _ (sudo), rd, grep variants, afind, globurl
- Add missing OMZ plugins: command-not-found, colored-man-pages, kubectl
2026-05-26 12:45:07 +08:00
luochen570
e6f99590c5 docs: update README to match current structure
- Add README.md paths in directory tree (hosts/, profiles/, home/)
- Add category descriptions to profiles
- Mark nixos-lxc as s0.sermc.net
- Add note about per-host README.md
2026-05-26 12:42:42 +08:00
luochen570
33c7f0b6fd sync: merge s0.sermc.net LXC configuration
- Add users.luochen570 user config
- Add nix substituters (Tsinghua mirror)
- Add nix experimental-features (nix-command, flakes)
- Set system.stateVersion to 25.05
2026-05-26 12:40:25 +08:00
luochen570
c92c904e76 chore: clean up and optimize nixos configuration
- fix: nvidia.nix missing semicolon (build error)
- remove: ranger, vim from core/pkg.nix (yazi + neovim covers)
- remove: htop duplicate in home/pkg.nix (keep in system)
- replace: neofetch with fastfetch in home/pkg.nix
- remove: nixd LSP, keep nil only in nvchad.nix
- remove: empty server/pkg.nix and no-op server/firewall.nix
- remove: redundant services.pulseaudio.enable = false default
- add: comprehensive README.md documenting architecture
2026-05-24 10:36:23 +08:00
luochen570
4488256039 modified: hosts/desktop/configuration.nix
modified:   hosts/desktop/hardware-configuration.nix
	modified:   modules/drivers/nvidia.nix
添加并整理了desktop的配置文件
2026-03-02 16:41:56 +08:00
luochen570
81cee2d50e 修改: hosts/desktop/configuration.nix
新文件:   hosts/desktop/hardware-configuration.nix
2026-03-02 16:34:23 +08:00
luochen570
5e57bc60c9 我 。。。。。
写不动了,感觉自己像个傻子一样
2026-03-01 20:42:58 +08:00
luochen570
d4323dd7ae modified: home/pkg.nix 2026-03-01 20:39:59 +08:00
luochen570
8df8cb4fb7 modified: home/pkg.nix
甘 天才luochen570文件冲突了
我真是个天才
2026-03-01 20:38:44 +08:00
luochen570
fbdaccbf84 modified: home/default.nix
甘
刚刚忘了添加引用了,补上了
2026-03-01 20:36:38 +08:00
luochen570
1f3ebf04f2 new file: home/pkg.nix
modified:   home/default.nix
添加部分用户级应用
2026-03-01 20:34:00 +08:00
luochen570
e4d82bc580 modified: README.md
modified:   flake.nix
	modified:   home/README.md
	modified:   home/ssh.nix
	modified:   hosts/README.md
	modified:   hosts/desktop/README.md
	modified:   hosts/desktop/configuration.nix
	new file:   hosts/nixos-lxc/README.md
	new file:   hosts/nixos-lxc/configuration.nix
	renamed:    modules/wsl/default.nix -> hosts/nixos-lxc/default.nix
	modified:   hosts/server/README.md
	modified:   hosts/server/configuration.nix
	modified:   hosts/virtualbox/README.md
	modified:   hosts/virtualbox/configuration.nix
	modified:   hosts/virtualbox/hardware-configuration.nix
	modified:   hosts/wsl/README.md
	modified:   hosts/wsl/configuration.nix
	modified:   lib/README.md
	modified:   lib/hosts.nix
	modified:   lib/mkHost.nix
	modified:   modules/README.md
	modified:   modules/core/README.md
	modified:   modules/core/core.nix
	modified:   modules/core/users.nix
	modified:   modules/desktop/README.md
	modified:   modules/desktop/de/README.md
	modified:   modules/desktop/wm/README.md
	modified:   modules/desktop/wm/default.nix
	modified:   modules/drivers/README.md
	modified:   modules/drivers/amdgpu.nix
	modified:   modules/server/README.md
	modified:   modules/server/default.nix
	new file:   modules/server/firewall.nix
	modified:   modules/server/pkg.nix
	modified:   modules/server/ssh.nix
	modified:   modules/server/virtualbox-guest.nix
	deleted:    modules/wsl/README.md
	deleted:    modules/wsl/configuration.nix
	modified:   overlays/README.md
	modified:   profiles/README.md
	modified:   profiles/desktop.nix
	new file:   profiles/lxc.nix
	modified:   profiles/wsl.nix
	modified:   secrets/README.md
	modified:   secrets/users/README.md
添加了pve-lxc的配置文件 删除了wsl的配置文件
2026-03-01 19:38:51 +08:00
luochen570
26b5caa6d0 new file: flake.lock
modified:   home/git.nix
	modified:   hosts/README.md
	modified:   hosts/virtualbox/README.md
	modified:   hosts/virtualbox/configuration.nix
	modified:   modules/core/users.nix
	modified:   modules/desktop/pkg.nix
	modified:   modules/server/README.md
	modified:   profiles/README.md
2026-02-28 11:14:50 +08:00
luochen570
3659dc3e50 modified: .sops.yaml
modified:   flake.nix
	modified:   home/git.nix
	modified:   home/nvchad.nix
	modified:   home/ssh.nix
	modified:   home/zsh.nix
	new file:   hosts/virtualbox/README.md
	new file:   hosts/virtualbox/configuration.nix
	new file:   hosts/virtualbox/default.nix
	new file:   hosts/virtualbox/hardware-configuration.nix
	modified:   lib/hosts.nix
	modified:   modules/core/README.md
	new file:   modules/core/core.nix
	modified:   modules/core/default.nix
	new file:   modules/core/pkg.nix
	modified:   modules/core/sops.nix
	modified:   modules/desktop/README.md
	modified:   modules/desktop/apps.nix
	modified:   modules/desktop/default.nix
	new file:   modules/desktop/fcitx5.nix
	new file:   modules/desktop/pkg.nix
	modified:   modules/server/README.md
	modified:   modules/server/default.nix
	modified:   modules/server/docker.nix
	new file:   modules/server/pkg.nix
	modified:   modules/server/ssh.nix
	new file:   modules/server/virtualbox-guest.nix
	new file:   modules/server/vscode-server.nix
	modified:   modules/wsl/configuration.nix
	new file:   profiles/virtualbox.nix
	modified:   profiles/wsl.nix
	modified:   secrets/users/README.md
	modified:   secrets/users/luochen570.enc.yaml.example
2026-02-28 10:21:32 +08:00
65 changed files with 954 additions and 222 deletions

View File

@@ -2,4 +2,4 @@ creation_rules:
- path_regex: ^secrets/users/.*\.ya?ml$
key_groups:
- age:
- age1REPLACE_WITH_YOUR_AGE_PUBLIC_KEY
- age1REPLACE_WITH_YOUR_AGE_PUBLIC_KEY

123
README.md
View File

@@ -1,18 +1,113 @@
# 📦 nixos 配置仓库
# NixOS Configuration
基于 Flake 的 NixOS 多主机配置
洛尘luochen570的 NixOS 配置仓库,采用 Flakes + home-manager + sops-nix 架构
## 🌲 目录树
```text
📦 nixos
├─ 🏠 home/ # Home Manager 用户配置default.nix 聚合)
├─ 🖥️ hosts/ # 主机入口
├─ 🧩 lib/ # 公共函数mkHost
├─ 🧱 modules/ # 系统模块core/server/wsl
├─ 🎨 overlays/ # 包覆盖
├─ 📚 profiles/ # 场景组合desktop/server/wsl
└─ 🔐 secrets/ # sops 密钥模板与密文
## 架构
```
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
```
## 🔗 引用关系
`flake.nix` -> `lib/hosts.nix` + `lib/mkHost.nix` -> `hosts/*` + `profiles/*` -> `modules/*/default.nix` -> 子模块
## 主机列表
| 主机 | 角色 | 架构 | 说明 |
|------|------|------|------|
| `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 中引用

263
flake.lock generated Normal file
View File

@@ -0,0 +1,263 @@
{
"nodes": {
"flake-compat": {
"flake": false,
"locked": {
"lastModified": 1767039857,
"narHash": "sha256-vNpUSpF5Nuw8xvDLj2KCwwksIbjua2LZCqhV1LNRDns=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "5edf11c44bc78a0d334f6334cdaf7d60d732daab",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1731533236,
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"flake-utils_2": {
"inputs": {
"systems": "systems_2"
},
"locked": {
"lastModified": 1681202837,
"narHash": "sha256-H+Rh19JDwRtpVPAWp64F+rlEtxUWBAQW28eAi3SRSzg=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "cfacdce06f30d2b68473a46042957675eebb3401",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"home-manager": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1763992789,
"narHash": "sha256-WHkdBlw6oyxXIra/vQPYLtqY+3G8dUVZM8bEXk0t8x4=",
"owner": "nix-community",
"repo": "home-manager",
"rev": "44831a7eaba4360fb81f2acc5ea6de5fde90aaa3",
"type": "github"
},
"original": {
"owner": "nix-community",
"ref": "release-25.05",
"repo": "home-manager",
"type": "github"
}
},
"nix4nvchad": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": [
"nixpkgs"
],
"nvchad-starter": "nvchad-starter"
},
"locked": {
"lastModified": 1772187015,
"narHash": "sha256-8UA+HVKxRqyv1wuAln4gxskq8ZbW5ttKZg5kDp0R154=",
"owner": "nix-community",
"repo": "nix4nvchad",
"rev": "cde302611dfdcaece9756b48f68eb808645929b5",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "nix4nvchad",
"type": "github"
}
},
"nixos-wsl": {
"inputs": {
"flake-compat": "flake-compat",
"nixpkgs": "nixpkgs"
},
"locked": {
"lastModified": 1771563879,
"narHash": "sha256-vA5hocvdGhr+jfBN7A7ogeZqIz2qx01EixXwdVsQcnE=",
"owner": "nix-community",
"repo": "NixOS-WSL",
"rev": "379d20c55f552e91fb9f3f0382e4a97d3f452943",
"type": "github"
},
"original": {
"owner": "nix-community",
"ref": "main",
"repo": "NixOS-WSL",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1770019141,
"narHash": "sha256-VKS4ZLNx4PNrABoB0L8KUpc1fE7CLpQXQs985tGfaCU=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "cb369ef2efd432b3cdf8622b0ffc0a97a02f3137",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1767313136,
"narHash": "sha256-16KkgfdYqjaeRGBaYsNrhPRRENs0qzkQVUooNHtoy2w=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "ac62194c3917d5f474c1a844b6fd6da2db95077d",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-25.05",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_3": {
"locked": {
"lastModified": 1682134069,
"narHash": "sha256-TnI/ZXSmRxQDt2sjRYK/8j8iha4B4zP2cnQCZZ3vp7k=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "fd901ef4bf93499374c5af385b2943f5801c0833",
"type": "github"
},
"original": {
"id": "nixpkgs",
"type": "indirect"
}
},
"nvchad-starter": {
"flake": false,
"locked": {
"lastModified": 1753939018,
"narHash": "sha256-xdLr6tlU9uA+wu0pqha2br0fdVm+1MjgjbB5awz9ICU=",
"owner": "NvChad",
"repo": "starter",
"rev": "e3572e1f5e1c297212c3deeb17b7863139ce663e",
"type": "github"
},
"original": {
"owner": "NvChad",
"ref": "main",
"repo": "starter",
"type": "github"
}
},
"root": {
"inputs": {
"home-manager": "home-manager",
"nix4nvchad": "nix4nvchad",
"nixos-wsl": "nixos-wsl",
"nixpkgs": "nixpkgs_2",
"sops-nix": "sops-nix",
"vscode-server": "vscode-server"
}
},
"sops-nix": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1772048434,
"narHash": "sha256-/wA0OaH6kZ/pFA+nXR/tvg5oupOmEDmMS5us79JT60o=",
"owner": "Mic92",
"repo": "sops-nix",
"rev": "334daa7c273dd8bf7a0cd370e4e16022b64e55e9",
"type": "github"
},
"original": {
"owner": "Mic92",
"repo": "sops-nix",
"type": "github"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
},
"systems_2": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
},
"vscode-server": {
"inputs": {
"flake-utils": "flake-utils_2",
"nixpkgs": "nixpkgs_3"
},
"locked": {
"lastModified": 1770124655,
"narHash": "sha256-yHmd2B13EtBUPLJ+x0EaBwNkQr9LTne1arLVxT6hSnY=",
"owner": "nix-community",
"repo": "nixos-vscode-server",
"rev": "92ce71c3ba5a94f854e02d57b14af4997ab54ef0",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "nixos-vscode-server",
"type": "github"
}
}
},
"root": "root",
"version": 7
}

View File

@@ -1,5 +1,5 @@
{
description = "My Infra";
description = "luochen570's NixOS configuration";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.05";
@@ -9,15 +9,19 @@
inputs.nixpkgs.follows = "nixpkgs";
};
# Nix4NvChad
nix4nvchad = {
url = "github:nix-community/nix4nvchad";
inputs.nixpkgs.follows = "nixpkgs";
};
# NixOS WSL
nixos-wsl.url = "github:nix-community/NixOS-WSL/main";
# VS Code Server
vscode-server.url = "github:nix-community/nixos-vscode-server";
# SOPS for Nix
sops-nix = {
url = "github:Mic92/sops-nix";
inputs.nixpkgs.follows = "nixpkgs";

View File

@@ -1,4 +1,4 @@
# 🏠 home 目录说明
# 🏠 home 目录说明
Home Manager 用户级配置目录。
@@ -11,3 +11,5 @@ Home Manager 用户级配置目录。
├─ 💻 zsh.nix # Zsh 与插件
└─ ✨ nvchad.nix # Neovim(NvChad)
```
`r`n

View File

@@ -1,6 +1,7 @@
{ ... }:
{
imports = [
./pkg.nix
./git.nix
./ssh.nix
./zsh.nix

View File

@@ -2,11 +2,9 @@
{
programs.git = {
enable = true;
settings = {
user = {
name = "luochen570";
email = "1160510664@qq.com";
};
userName = "luochen570";
userEmail = "1160510664@qq.com";
extraConfig = {
init.defaultBranch = "main";
};
};

View File

@@ -1,29 +1,28 @@
{ config, pkgs, inputs, system, ... }:
{
# 导入 NvChad 模块
imports = [
inputs.nix4nvchad.homeManagerModules.default
];
programs.nvchad = {
enable = true;
# 可选:添加你需要的语言服务器和工具
extraPackages = with pkgs; [
# LSP 服务器
nil # Nix LSP
nixd # Nix 语言服务器(另一种选择)
marksman # Markdown LSP
# 格式化工具
nixpkgs-fmt
shfmt
];
};
# 设置默认编辑器
home.sessionVariables = {
EDITOR = "nvim";
VISUAL = "nvim";
};
}
{ config, pkgs, inputs, system, ... }:
{
# 导入 NvChad 模块
imports = [
inputs.nix4nvchad.homeManagerModules.default
];
programs.nvchad = {
enable = true;
# NvChad 需要的额外包
extraPackages = with pkgs; [
# LSP 服务器
nil # Nix LSP
marksman # Markdown LSP
# 格式化工具
nixpkgs-fmt
shfmt
];
};
# 设置默认编辑器
home.sessionVariables = {
EDITOR = "nvim";
VISUAL = "nvim";
};
}

16
home/pkg.nix Normal file
View File

@@ -0,0 +1,16 @@
{ pkgs, ... }:
{
home.packages = with pkgs; [
# 文件/磁盘工具
duf
ncdu
yazi
fastfetch
# Shell 工具zsh aliases 依赖)
eza # ls/eza aliases
bat # cat alias (bat -pp)
ack # afind alias
fzf # fzf-tab 依赖
];
}

View File

@@ -2,7 +2,11 @@
{
programs.ssh.enable = true;
# ~/.ssh/config comes from a sops secret file.
# ~/.ssh/id_rsa 来自 sops secret 文件。
home.file.".ssh/id_rsa".source =
config.lib.file.mkOutOfStoreSymlink "/run/secrets/users/luochen570/ssh_private_key";
# ~/.ssh/config 来自 sops secret 文件。
home.file.".ssh/config".source =
config.lib.file.mkOutOfStoreSymlink "/run/secrets/users/luochen570/ssh_config";
}

View File

@@ -1,10 +1,52 @@
{ config, pkgs, inputs, system, ... }:
{ programs.zsh = {
{
programs.zsh = {
enable = true;
enableCompletion = true;
autosuggestion.enable = true;
syntaxHighlighting.enable = true;
# initContent = "source ~/.p10k.zsh";
# 环境变量 - 对应 .zshrc 开头的环境设置
envExtra = ''
path=(~/.local/bin $path)
export XDG_CONFIG_HOME="''${XDG_CONFIG_HOME:-$HOME/.config}"
export POWERLEVEL9K_INSTANT_PROMPT=quiet
export PATH="$HOME/.hermes/node/bin:$PATH"
'';
# Shell 选项 - 对应 .zshrc 的 setoptNixOS 中需写在 initExtra 里)
# options 属性在 home-manager 中不存在,用 setopt 命令代替
# 初始化 - 对应 .zshrc 中的 Powerlevel10k instant prompt 和函数定义
initExtra = ''
# Shell options
setopt correct
setopt interactive_comments
# Powerlevel10k instant prompt
if [[ -r "''${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-''${(%):-%n}.zsh" ]]; then
source "''${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-''${(%):-%n}.zsh"
fi
# Powerlevel10k config
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh
# yazi: open and jump to last cwd
function y() {
local tmp cwd
tmp="$(mktemp -t yazi-cwd.XXXXXX)"
yazi "$@" --cwd-file="$tmp"
cwd="$(cat -- "$tmp")"
if [[ -n "$cwd" && "$cwd" != "$PWD" ]]; then
builtin cd -- "$cwd"
fi
rm -f -- "$tmp"
}
#
alias proxy-on='export http_proxy=http://127.0.0.1:7890 https_proxy=http://127.0.0.1:7890'
alias proxy-off='unset http_proxy https_proxy'
'';
plugins = [
{
name = "powerlevel10k";
@@ -15,25 +57,41 @@
name = "fzf-tab";
src = "${pkgs.zsh-fzf-tab}/share/fzf-tab";
}
# {
# name = "powerlevel10k-config";
# src = "/home/luochen570/nixos-config/modules/home/p10k/";
# file = "p10k.zsh";
# }
];
# 设置alias
shellAliases = {
# Git相关
gc1 = "git clone --recursive --depth=1";
# 目录操作
md = "mkdir -p";
# 设置 alias - 对应 .zshrc 中的 aliases 部分
shellAliases = {
# 目录导航
"..." = "../..";
"...." = "../../..";
"....." = "../../../..";
"......" = "../../../../..";
"1" = "cd -";
"2" = "cd -2";
"3" = "cd -3";
"4" = "cd -4";
"5" = "cd -5";
"6" = "cd -6";
"7" = "cd -7";
"8" = "cd -8";
"9" = "cd -9";
# eza/ls替代
# 快捷操作
"_" = "sudo ";
gc1 = "git clone --recursive --depth=1";
# 目录操作
md = "mkdir -p";
rd = "rmdir";
# grep
grep = "grep --color=auto";
egrep = "egrep --color=auto";
fgrep = "fgrep --color=auto";
afind = "ack -il";
globurl = "noglob urlglobber ";
# eza/ls 替代
ls = "eza --color=auto";
l = "eza -lbah --icons=auto";
la = "eza -labgh --icons=auto";
@@ -42,7 +100,7 @@
lsa = "eza -lbagR --icons=auto";
lst = "eza -lTabgh --icons=auto";
# bat/cat替代
# bat/cat 替代
cat = "bat -pp";
ccat = "cat";
};
@@ -54,8 +112,10 @@
"z"
"extract"
"git"
# "fzf-tab"
"command-not-found"
"colored-man-pages"
"kubectl"
];
};
};
}
}

View File

@@ -1,4 +1,4 @@
# 🖥️ hosts 目录说明
# 🖥️ hosts 目录说明
主机入口层。每台主机目录固定为三文件结构:
- `default.nix`:统一入口,导入 `configuration.nix`
@@ -16,8 +16,12 @@
│ ├─ 🧩 default.nix
│ ├─ ⚙️ configuration.nix
│ └─ 📝 README.md
└─ 🪟 wsl/
└─ 📦 virtualbox/
├─ 🧩 default.nix
├─ ⚙️ configuration.nix
├─ 🧱 hardware-configuration.nix
└─ 📝 README.md
```
`r`n

View File

@@ -1,4 +1,4 @@
# 🧑‍💻 hosts/desktop
# 🧑‍💻 hosts/desktop
桌面主机入口。
@@ -9,3 +9,5 @@
├─ ⚙️ configuration.nix # profile + hostName + 机器相关配置
└─ 📝 README.md
```
`r`n

View File

@@ -1,11 +1,22 @@
{ ... }:
{
# 可在此合并由 nixos-generate-config 生成的机器专属配置:
# 磁盘布局、引导加载器、文件系统、硬件选项等。
imports = [
../../profiles/desktop.nix
../../modules/drivers/nvidia.nix
../../modules/drivers/amdgpu.nix
];
networking.hostName = "desktop";
# Bootloader.
boot.loader.systemd-boot.enable = true;
boot.loader.efi.canTouchEfiVariables = true;
# Machine-specific config generated by nixos-generate-config can be
# merged here: disk layout, boot loader, filesystem, hardware options.
# Enable sound with pipewire.
security.rtkit.enable = true;
services.pipewire = {
enable = true;
alsa.enable = true;
alsa.support32Bit = true;
pulse.enable = true;
};
}

View File

@@ -0,0 +1,41 @@
# Do not modify this file! It was generated by nixos-generate-config
# and may be overwritten by future invocations. Please make changes
# to /etc/nixos/configuration.nix instead.
{ config, lib, pkgs, modulesPath, ... }:
{
imports =
[ (modulesPath + "/installer/scan/not-detected.nix")
];
boot.initrd.availableKernelModules = [ "nvme" "xhci_pci" "ahci" "usbhid" "usb_storage" "sd_mod" ];
boot.initrd.kernelModules = [ ];
boot.kernelModules = [ "kvm-amd" ];
boot.extraModulePackages = [ ];
fileSystems."/" =
{ device = "/dev/disk/by-uuid/2451064c-5eeb-4855-9f32-32e814f1edfc";
fsType = "ext4";
};
fileSystems."/boot" =
{ device = "/dev/disk/by-uuid/40A8-BBC4";
fsType = "vfat";
options = [ "fmask=0077" "dmask=0077" ];
};
fileSystems."/home" =
{ device = "/dev/disk/by-uuid/6e5d3960-435c-4c4d-9c42-3d2f42c3a4af";
fsType = "ext4";
};
swapDevices = [ ];
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
# Enable OpenGL
hardware.graphics = {
enable = true;
};
}

14
hosts/nixos-lxc/README.md Normal file
View File

@@ -0,0 +1,14 @@
# 📦 hosts/nixos-lxc
Proxmox LXC 主机入口。
## 🌲 目录树
```text
hosts/nixos-lxc
├─ default.nix
├─ configuration.nix
└─ README.md
```
`r`n

View File

@@ -0,0 +1,30 @@
{ modulesPath, ... }:
{
imports = [
(modulesPath + "/virtualisation/proxmox-lxc.nix")
];
# 修复 LXC 挂载报错
systemd.mounts = [
{ where = "/sys/kernel/debug"; enable = false; }
{ where = "/sys/fs/fuse/connections"; enable = false; }
];
systemd.services."sys-kernel-debug.mount".enable = false;
# 容器运行时设置
nix.settings.sandbox = false;
proxmoxLXC = {
manageNetwork = false;
privileged = true;
};
# 由宿主机处理 fstrim
services.fstrim.enable = false;
services.resolved = {
extraConfig = ''
Cache=true
CacheFromLocalhost=true
'';
};
}

View File

@@ -1,4 +1,5 @@
{ ... }:
{
imports = [
./configuration.nix

View File

@@ -1,4 +1,4 @@
# 🗄️ hosts/server
# 🗄️ hosts/server
服务器主机入口。
@@ -9,3 +9,5 @@
├─ ⚙️ configuration.nix # profile + hostName + 机器相关配置
└─ 📝 README.md
```
`r`n

View File

@@ -1,11 +1,5 @@
{ ... }:
{
imports = [
../../profiles/server.nix
];
networking.hostName = "server";
# Machine-specific config generated by nixos-generate-config can be
# merged here: disk layout, boot loader, filesystem, hardware options.
# 可在此合并由 nixos-generate-config 生成的机器专属配置:
# 磁盘布局、引导加载器、文件系统、硬件选项等。
}

View File

@@ -0,0 +1,14 @@
# 📦 hosts/virtualbox
VirtualBox 虚拟机主机入口。
## 🌲 目录树
```text
📦 hosts/virtualbox
├─ 🧩 default.nix # 主机入口,引用 configuration.nix 与硬件配置
├─ ⚙️ configuration.nix # profile + hostName + 机器相关配置
├─ 🧱 hardware-configuration.nix # 由 nixos-generate-config 生成的硬件配置
└─ 📝 README.md
```
`r`n

View File

@@ -0,0 +1,8 @@
{ ... }:
{
boot.loader.systemd-boot.enable = true;
boot.loader.efi.canTouchEfiVariables = true;
# 可在此合并由 nixos-generate-config 生成的机器专属配置:
# 磁盘布局、引导加载器、文件系统、硬件选项等。
}

View File

@@ -0,0 +1,7 @@
{ ... }:
{
imports = [
./configuration.nix
./hardware-configuration.nix
];
}

View File

@@ -0,0 +1,29 @@
# 请勿直接修改此文件!它由 `nixos-generate-config` 自动生成,
# 后续再次执行生成命令时可能会被覆盖。请改动
# /etc/nixos/configuration.nix。
{ config, lib, pkgs, modulesPath, ... }:
{
imports = [ ];
boot.initrd.availableKernelModules = [ "ata_piix" "ohci_pci" "ehci_pci" "ahci" "sd_mod" "sr_mod" ];
boot.initrd.kernelModules = [ ];
boot.kernelModules = [ ];
boot.extraModulePackages = [ ];
fileSystems."/" =
{ device = "/dev/disk/by-uuid/31ec1b9d-9138-4051-86ed-51dc63f2619b";
fsType = "ext4";
};
fileSystems."/boot" =
{ device = "/dev/disk/by-uuid/935D-FCF6";
fsType = "vfat";
options = [ "fmask=0022" "dmask=0022" ];
};
swapDevices = [ ];
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
virtualisation.virtualbox.guest.enable = true;
}

View File

@@ -1,4 +1,4 @@
# 🪟 hosts/wsl
# 🪟 hosts/wsl
WSL 主机入口。
@@ -9,3 +9,5 @@ WSL 主机入口。
├─ ⚙️ configuration.nix # profile + hostName可加 WSL 机器项)
└─ 📝 README.md
```
`r`n

View File

@@ -1,10 +1,11 @@
{ ... }:
{ username, inputs, ... }:
{
imports = [
../../profiles/wsl.nix
inputs.nixos-wsl.nixosModules.default
];
networking.hostName = "nixos-wsl";
# Keep minimal for WSL. Add machine-specific options here if needed.
wsl = {
enable = true;
defaultUser = username;
};
}

View File

@@ -1,4 +1,4 @@
# 🧩 lib 目录说明
# 🧩 lib 目录说明
公共函数目录。
@@ -8,3 +8,5 @@
├─ ⚙️ mkHost.nix # 组装 NixOS system 与 Home Manager接收 username
└─ 📋 hosts.nix # 主机清单system/profile 映射)
```
`r`n

View File

@@ -2,15 +2,30 @@
desktop = {
system = "x86_64-linux";
profile = "desktop";
hostName = "desktop";
};
server = {
system = "x86_64-linux";
profile = "server";
hostName = "server";
};
wsl = {
system = "x86_64-linux";
profile = "wsl";
hostName = "nixos-wsl";
};
virtualbox = {
system = "x86_64-linux";
profile = "virtualbox";
hostName = "virtualbox";
};
nixos-lxc = {
system = "x86_64-linux";
profile = "lxc";
hostName = "nixos-lxc";
};
}

View File

@@ -1,6 +1,8 @@
{ nixpkgs, home-manager, inputs }:
{
hostname,
hostName ? hostname,
systemStateVersion ? "25.05",
system,
profile,
username,
@@ -17,6 +19,10 @@ nixpkgs.lib.nixosSystem {
inputs.sops-nix.nixosModules.sops
../hosts/${hostname}
../profiles/${profile}.nix
{
networking.hostName = hostName;
system.stateVersion = systemStateVersion;
}
home-manager.nixosModules.home-manager
{
home-manager.useGlobalPkgs = true;

View File

@@ -1,4 +1,4 @@
# 🧱 modules 目录说明
# 🧱 modules 目录说明
系统模块目录。大部分子目录通过 `default.nix` 提供统一入口,驱动目录采用按文件显式引用。
@@ -8,6 +8,8 @@
├─ 🧭 core/ # 全局基础模块
├─ 🖥️ desktop/ # 桌面模块DE/WM/应用)
├─ 🎮 drivers/ # 硬件驱动模块(如 NVIDIA
─ 🗄️ server/ # 服务器模块
└─ 🪟 wsl/ # WSL 模块
─ 🗄️ server/ # 服务器模块
```
`r`n

View File

@@ -1,4 +1,4 @@
# 🧭 modules/core
# 🧭 modules/core
所有主机场景都会引入的基础模块。
@@ -6,6 +6,9 @@
```text
🧭 modules/core
├─ 🧩 default.nix # 基础 imports + 时区/镜像源/flakes 等默认设置
├─ 📦 pkg.nix # 全局基础软件包
├─ 👤 users.nix # 用户、默认 shell、密码与公钥
└─ 🔐 sops.nix # sops-nix secret 映射
```
`r`n

30
modules/core/core.nix Normal file
View File

@@ -0,0 +1,30 @@
{ lib, ... }:
{
nix.settings = {
experimental-features = [ "nix-command" "flakes" ];
auto-optimise-store = true;
substituters = [
"https://cache.nixos.org"
"https://mirrors.tuna.tsinghua.edu.cn/nix-channels/store"
"https://mirror.sjtu.edu.cn/nix-channels/store"
];
trusted-public-keys = [
"cache.nixos.org-1:6NCHdD59X431o0gWypbtr1HEhF2M7wP6+jJj6Jm23UM="
];
};
nix.gc = {
automatic = true;
dates = "weekly";
options = "--delete-older-than 14d";
};
nixpkgs.config.allowUnfree = true;
time.timeZone = lib.mkDefault "Asia/Shanghai";
i18n.defaultLocale = lib.mkDefault "zh_CN.UTF-8";
# 允许 wheel 组免密 sudo
security.sudo.wheelNeedsPassword = false;
}

View File

@@ -1,46 +1,9 @@
{ lib, pkgs, ... }:
{ ... }:
{
imports = [
./core.nix
./pkg.nix
./users.nix
./sops.nix
];
nix.settings = {
experimental-features = [ "nix-command" "flakes" ];
auto-optimise-store = true;
substituters = [
"https://cache.nixos.org"
"https://mirrors.tuna.tsinghua.edu.cn/nix-channels/store"
"https://mirror.sjtu.edu.cn/nix-channels/store"
];
trusted-public-keys = [
"cache.nixos.org-1:6NCHdD59X431o0gWypbtr1HEhF2M7wP6+jJj6Jm23UM="
];
};
nix.gc = {
automatic = true;
dates = "weekly";
options = "--delete-older-than 14d";
};
nixpkgs.config.allowUnfree = true;
time.timeZone = lib.mkDefault "Asia/Shanghai";
i18n.defaultLocale = lib.mkDefault "zh_CN.UTF-8";
networking.firewall.enable = lib.mkDefault true;
environment.systemPackages = with pkgs; [
curl
eza
git
htop
ranger
vim
wget
];
system.stateVersion = lib.mkDefault "25.05";
}
}

12
modules/core/pkg.nix Normal file
View File

@@ -0,0 +1,12 @@
{ pkgs, ... }:
{
environment.systemPackages = with pkgs; [
curl
git
htop
wget
# 系统级工具(多个 host 共用)
kubectl # oh-my-zsh kubectl plugin
];
}

View File

@@ -11,6 +11,11 @@ in
defaultSopsFile = secretFile;
secrets = lib.mkIf (builtins.pathExists secretFile) {
"users/luochen570/authorized_key" = {};
"users/luochen570/ssh_private_key" = {
owner = "luochen570";
group = "users";
mode = "0400";
};
"users/luochen570/ssh_config" = {
owner = "luochen570";
group = "users";

View File

@@ -5,19 +5,16 @@
users.users.${username} = {
isNormalUser = true;
extraGroups = [ "wheel" ];
extraGroups = [ "wheel" "networkmanager" ];
shell = pkgs.zsh;
}
// lib.optionalAttrs (!(config.sops.secrets ? "users/luochen570/passwordHash")) {
initialPassword = "Dly928730@..";
}
// lib.optionalAttrs (config.sops.secrets ? "users/luochen570/authorized_key") {
openssh.authorizedKeys.keyFiles = [ config.sops.secrets."users/luochen570/authorized_key".path ];
}
// lib.optionalAttrs (config.sops.secrets ? "users/luochen570/passwordHash") {
hashedPasswordFile = config.sops.secrets."users/luochen570/passwordHash".path;
};
users.users.${username}.initialPassword = lib.mkIf
(!(config.sops.secrets ? "users/luochen570/passwordHash"))
"Dly928730@..";
users.users.${username}.openssh.authorizedKeys.keyFiles = lib.mkIf
(config.sops.secrets ? "users/luochen570/authorized_key")
[ config.sops.secrets."users/luochen570/authorized_key".path ];
users.users.${username}.hashedPasswordFile = lib.mkIf
(config.sops.secrets ? "users/luochen570/passwordHash")
config.sops.secrets."users/luochen570/passwordHash".path;
}

View File

@@ -1,12 +1,15 @@
# 🖥️ modules/desktop 目录说明
# 🖥️ modules/desktop 目录说明
桌面能力模块按“桌面环境DE/窗口管理器WM/应用”拆分,便于后续扩展到多种桌面方案。
## 🌲 目录树
```text
🖥️ modules/desktop
├─ 📦 default.nix # 聚合入口de + apps
├─ 📦 default.nix # 聚合入口de + pkg + apps
├─ 🧭 de/ # 桌面环境模块(例如 KDE
├─ 🪟 wm/ # 窗口管理器模块(预留)
├─ 📦 pkg.nix # 桌面软件包
└─ 📱 apps.nix # 桌面应用与默认浏览器关联
```
`r`n

View File

@@ -1,19 +1,10 @@
{ pkgs, ... }:
{ ... }:
{
environment.systemPackages = with pkgs; [
firefox
google-chrome
linuxqq
wechat-uos
xterm
kdePackages.kate
kdePackages.konsole
];
xdg.mime.enable = true;
xdg.mime.defaultApplications = {
"text/html" = [ "google-chrome.desktop" ];
"application/xhtml+xml" = [ "google-chrome.desktop" ];
"x-scheme-handler/http" = [ "google-chrome.desktop" ];
"x-scheme-handler/https" = [ "google-chrome.desktop" ];
};
}
}

View File

@@ -1,4 +1,4 @@
# 🧭 modules/desktop/de 目录说明
# 🧭 modules/desktop/de 目录说明
桌面环境Desktop Environment目录。
@@ -8,3 +8,5 @@
├─ 📦 default.nix # 聚合入口(当前仅 KDE
└─ ⚙️ kde.nix # SDDM + Plasma 6
```
`r`n

View File

@@ -2,6 +2,8 @@
{
imports = [
./de
./pkg.nix
./apps.nix
./fcitx5.nix
];
}
}

View File

@@ -0,0 +1,20 @@
{ pkgs, ... }:
{
i18n.inputMethod = {
enabled = "fcitx5";
fcitx5.addons = with pkgs; [
fcitx5-rime
fcitx5-configtool
fcitx5-gtk
fcitx5-chinese-addons
];
};
environment.sessionVariables = {
GTK_IM_MODULE = "fcitx";
QT_IM_MODULE = "fcitx";
XMODIFIERS = "@im=fcitx";
SDL_IM_MODULE = "fcitx";
GLFW_IM_MODULE = "fcitx";
};
}

12
modules/desktop/pkg.nix Normal file
View File

@@ -0,0 +1,12 @@
{ pkgs, ... }:
{
environment.systemPackages = with pkgs; [
firefox
google-chrome
qq
wechat
xterm
kdePackages.kate
kdePackages.konsole
];
}

View File

@@ -1,4 +1,4 @@
# 🪟 modules/desktop/wm 目录说明
# 🪟 modules/desktop/wm 目录说明
窗口管理器Window Manager目录当前为预留结构。
@@ -7,3 +7,5 @@
🪟 modules/desktop/wm
└─ 📦 default.nix # 预留 future importshyprland/sway 等)
```
`r`n

View File

@@ -1,7 +1,7 @@
{ ... }:
{
imports = [
# Future WM modules:
# 未来可引入的 WM 模块:
# ./hyprland.nix
# ./sway.nix
];

View File

@@ -1,4 +1,4 @@
# 🎮 modules/drivers 目录说明
# 🎮 modules/drivers 目录说明
硬件驱动模块目录,用于集中管理显卡等驱动配置。
@@ -9,3 +9,5 @@
├─ 🔴 amdgpu.nix # AMD iGPU(9700X) 用户态图形/计算支持
└─ 📝 README.md
```
`r`n

View File

@@ -1,8 +1,8 @@
{ pkgs, ... }:
{
# Ryzen 7 9700X iGPU (RDNA2) related userspace support.
# Keep as a secondary GPU setup; X primary driver is still controlled
# by the desktop profile / nvidia module.
# Ryzen 7 9700X 核显RDNA2相关的用户态支持。
# 作为辅助显卡配置保留X 的主显卡驱动仍由
# desktop profile / nvidia 模块控制。
hardware.graphics = {
enable = true;
extraPackages = with pkgs; [

View File

@@ -7,6 +7,8 @@
modesetting.enable = true;
open = true;
nvidiaSettings = true;
powerManagement.enable = false;
powerManagement.finegrained = false;
package = config.boot.kernelPackages.nvidiaPackages.latest;
};

View File

@@ -0,0 +1,22 @@
# 📦 modules/optional
选装模块目录——非默认启用,按需在 profile 中引用。
## 🌲 目录树
```text
📦 modules/optional
├─ 📦 virtualbox-guest.nix # VirtualBox Guest 增强(加入 wheel 组、拖拽支持)
├─ 🧠 vscode-server.nix # VS Code Server + direnv + nix-ld
└─ 📝 README.md
```
## 用法
在对应 profile 或 host 配置中添加 import
```nix
imports = [
../modules/optional/virtualbox-guest.nix
../modules/optional/vscode-server.nix
];
```

View File

@@ -0,0 +1,6 @@
{ ... }:
{
# VirtualBox Guest 增强支持
virtualisation.virtualbox.guest.enable = true;
virtualisation.virtualbox.guest.dragAndDrop = true;
}

View File

@@ -0,0 +1,13 @@
{ inputs, ... }:
{
imports = [
inputs.vscode-server.nixosModules.default
];
services.vscode-server.enable = true;
programs.direnv.enable = true;
# 允许未打补丁的动态二进制文件在 NixOS 上运行
programs.nix-ld.enable = true;
}

View File

@@ -1,11 +1,19 @@
# 🗄️ modules/server
服务器专用模块
服务器专用核心模块(所有服务器主机默认启用)
## 🌲 目录树
```text
🗄️ modules/server
├─ 📦 default.nix # 聚合入口
├─ 🔐 ssh.nix # OpenSSH 参数
🐳 docker.nix # Docker 与清理策略
├─ 📦 default.nix # 聚合入口
├─ 🔐 ssh.nix # OpenSSH 参数
🔐 lxc-ssh.nix # LXC OpenSSH 覆盖参数
├─ 🐳 docker.nix # Docker 与清理策略
└─ 📝 README.md
```
## 可选模块
选装模块已移至 `modules/optional/`
- `virtualbox-guest.nix` — VirtualBox Guest 增强配置(用于 virtualbox profile
- `vscode-server.nix` — VS Code Server + direnv + nix-ld用于 wsl/virtualbox profile

View File

@@ -7,5 +7,5 @@
dates = "weekly";
};
};
}
}

View File

@@ -0,0 +1,8 @@
{
# LXC 容器需要密码登录
services.openssh.settings = {
PermitRootLogin = "prohibit-password";
PasswordAuthentication = true;
KbdInteractiveAuthentication = true;
};
}

View File

@@ -1,14 +1,13 @@
{ ... }:
{ lib, ... }:
{
services.openssh = {
enable = true;
settings = {
PasswordAuthentication = false;
KbdInteractiveAuthentication = false;
PermitRootLogin = "no";
X11Forwarding = false;
};
openFirewall = true;
settings = {
PasswordAuthentication = lib.mkDefault false;
KbdInteractiveAuthentication = lib.mkDefault false;
PermitRootLogin = lib.mkDefault "no";
X11Forwarding = lib.mkDefault false;
};
};
}

View File

@@ -1,11 +0,0 @@
# 🪟 modules/wsl
WSL 集成模块。
## 🌲 目录树
```text
🪟 modules/wsl
├─ 📦 default.nix # 聚合入口
├─ ⚙️ configuration.nix # WSL 配置实现
└─ 📝 README.md
```

View File

@@ -1,15 +0,0 @@
{ inputs, username, ... }:
{
imports = [
inputs.nixos-wsl.nixosModules.default
inputs.vscode-server.nixosModules.default
];
wsl = {
enable = true;
defaultUser = username;
};
services.vscode-server.enable = true;
users.users.${username}.extraGroups = [ "vscode" "docker" "wheel" ];
}

View File

@@ -1,4 +1,4 @@
# 🎨 overlays 目录说明
# 🎨 overlays 目录说明
`nixpkgs` 包覆盖目录。
@@ -7,3 +7,5 @@
🎨 overlays
└─ (自定义 overlay 文件)
```
`r`n

View File

@@ -1,4 +1,4 @@
# 📚 profiles 目录说明
# 📚 profiles 目录说明
场景化组合层,负责选择 `modules/*`
@@ -7,5 +7,9 @@
📚 profiles
├─ 🧑‍💻 desktop.nix # core + desktop + drivers
├─ 🗄️ server.nix # core + server(default.nix)
🪟 wsl.nix # core + wsl(default.nix)
📦 virtualbox.nix # core + desktop + virtualbox guest + 远程开发
├─ 🪟 wsl.nix # core + wsl(default.nix)
└─ 📦 lxc.nix # core + LXC 主机自定义配置
```
`r`n

View File

@@ -3,7 +3,5 @@
imports = [
../modules/core
../modules/desktop
../modules/drivers/nvidia.nix
../modules/drivers/amdgpu.nix
];
}

7
profiles/lxc.nix Normal file
View File

@@ -0,0 +1,7 @@
{
imports = [
../modules/core
../modules/server
../modules/server/lxc-ssh.nix
];
}

10
profiles/virtualbox.nix Normal file
View File

@@ -0,0 +1,10 @@
{ ... }:
{
imports = [
../modules/core
../modules/desktop
../modules/server/ssh.nix
../modules/optional/virtualbox-guest.nix
../modules/optional/vscode-server.nix
];
}

View File

@@ -2,9 +2,8 @@
{
imports = [
../modules/core
../modules/wsl
../modules/server/ssh.nix
../modules/optional/vscode-server.nix
];
networking.firewall.enable = false;
}

View File

@@ -1,4 +1,4 @@
# 🔐 secrets 目录说明
# 🔐 secrets 目录说明
`sops-nix` 密钥目录。
@@ -11,3 +11,5 @@
建议:
- 仅提交加密后的 `*.enc.yaml`
- 明文仅保留 `*.example` 模板
`r`n

View File

@@ -1,4 +1,4 @@
# 👤 secrets/users 目录说明
# 👤 secrets/users 目录说明
用户级 secret 模板与密文。
@@ -12,3 +12,6 @@
## 🔐 本地源文件Git 黑名单)
- 你可以在本目录维护 `*.source` 文件作为本地敏感源文件(例如真实域名和 IP
- 这些文件已被仓库 `.gitignore` 屏蔽,不会被 Git 收集和推送。
- 示例:`luochen570.ssh_config.source``luochen570.id_rsa.source`
`r`n

View File

@@ -4,6 +4,10 @@
users:
luochen570:
authorized_key: "ssh-rsa AAAA... your-comment"
ssh_private_key: |
-----BEGIN OPENSSH PRIVATE KEY-----
<REPLACE_WITH_REAL_PRIVATE_KEY>
-----END OPENSSH PRIVATE KEY-----
passwordHash: "REPLACE_WITH_mkpasswd_HASH"
ssh_config: |
# ~/.ssh/config