Compare commits
10 Commits
620b587010
...
4488256039
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4488256039 | ||
|
|
81cee2d50e | ||
|
|
5e57bc60c9 | ||
|
|
d4323dd7ae | ||
|
|
8df8cb4fb7 | ||
|
|
fbdaccbf84 | ||
|
|
1f3ebf04f2 | ||
|
|
e4d82bc580 | ||
|
|
26b5caa6d0 | ||
|
|
3659dc3e50 |
18
README.md
18
README.md
@@ -1,4 +1,4 @@
|
|||||||
# 📦 nixos 配置仓库
|
# 📦 nixos 配置仓库
|
||||||
|
|
||||||
基于 Flake 的 NixOS 多主机配置。
|
基于 Flake 的 NixOS 多主机配置。
|
||||||
|
|
||||||
@@ -10,9 +10,23 @@
|
|||||||
├─ 🧩 lib/ # 公共函数(mkHost)
|
├─ 🧩 lib/ # 公共函数(mkHost)
|
||||||
├─ 🧱 modules/ # 系统模块(core/server/wsl)
|
├─ 🧱 modules/ # 系统模块(core/server/wsl)
|
||||||
├─ 🎨 overlays/ # 包覆盖
|
├─ 🎨 overlays/ # 包覆盖
|
||||||
├─ 📚 profiles/ # 场景组合(desktop/server/wsl)
|
├─ 📚 profiles/ # 场景组合(desktop/server/wsl/virtualbox/lxc)
|
||||||
└─ 🔐 secrets/ # sops 密钥模板与密文
|
└─ 🔐 secrets/ # sops 密钥模板与密文
|
||||||
```
|
```
|
||||||
|
|
||||||
## 🔗 引用关系
|
## 🔗 引用关系
|
||||||
`flake.nix` -> `lib/hosts.nix` + `lib/mkHost.nix` -> `hosts/*` + `profiles/*` -> `modules/*/default.nix` -> 子模块
|
`flake.nix` -> `lib/hosts.nix` + `lib/mkHost.nix` -> `hosts/*` + `profiles/*` -> `modules/*/default.nix` -> 子模块
|
||||||
|
|
||||||
|
`networking.hostName` 由 `lib/mkHost.nix` 统一设置,具体值在 `lib/hosts.nix` 每台主机条目里定义。
|
||||||
|
|
||||||
|
## 🌐 Nix 模块引入文件树
|
||||||
|
```text
|
||||||
|
flake.nix
|
||||||
|
├─ lib/hosts.nix
|
||||||
|
├─ lib/mkHost.nix
|
||||||
|
│ ├─ hosts/<hostname>/default.nix -> configuration.nix
|
||||||
|
│ ├─ profiles/<profile>.nix -> modules/*
|
||||||
|
│ └─ home/default.nix -> home/*.nix
|
||||||
|
└─ modules/core/sops.nix -> secrets/users/*.enc.yaml
|
||||||
|
```
|
||||||
|
|
||||||
|
|||||||
263
flake.lock
generated
Normal file
263
flake.lock
generated
Normal 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
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
description = "My Infra";
|
description = "luochen570's NixOS configuration";
|
||||||
|
|
||||||
inputs = {
|
inputs = {
|
||||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.05";
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.05";
|
||||||
@@ -9,15 +9,19 @@
|
|||||||
inputs.nixpkgs.follows = "nixpkgs";
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
# Nix4NvChad
|
||||||
nix4nvchad = {
|
nix4nvchad = {
|
||||||
url = "github:nix-community/nix4nvchad";
|
url = "github:nix-community/nix4nvchad";
|
||||||
inputs.nixpkgs.follows = "nixpkgs";
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
# NixOS WSL
|
||||||
nixos-wsl.url = "github:nix-community/NixOS-WSL/main";
|
nixos-wsl.url = "github:nix-community/NixOS-WSL/main";
|
||||||
|
|
||||||
|
# VS Code Server
|
||||||
vscode-server.url = "github:nix-community/nixos-vscode-server";
|
vscode-server.url = "github:nix-community/nixos-vscode-server";
|
||||||
|
|
||||||
|
# SOPS for Nix
|
||||||
sops-nix = {
|
sops-nix = {
|
||||||
url = "github:Mic92/sops-nix";
|
url = "github:Mic92/sops-nix";
|
||||||
inputs.nixpkgs.follows = "nixpkgs";
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# 🏠 home 目录说明
|
# 🏠 home 目录说明
|
||||||
|
|
||||||
Home Manager 用户级配置目录。
|
Home Manager 用户级配置目录。
|
||||||
|
|
||||||
@@ -11,3 +11,5 @@ Home Manager 用户级配置目录。
|
|||||||
├─ 💻 zsh.nix # Zsh 与插件
|
├─ 💻 zsh.nix # Zsh 与插件
|
||||||
└─ ✨ nvchad.nix # Neovim(NvChad)
|
└─ ✨ nvchad.nix # Neovim(NvChad)
|
||||||
```
|
```
|
||||||
|
`r`n
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
{ ... }:
|
{ ... }:
|
||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
|
./pkg.nix
|
||||||
./git.nix
|
./git.nix
|
||||||
./ssh.nix
|
./ssh.nix
|
||||||
./zsh.nix
|
./zsh.nix
|
||||||
|
|||||||
@@ -2,11 +2,9 @@
|
|||||||
{
|
{
|
||||||
programs.git = {
|
programs.git = {
|
||||||
enable = true;
|
enable = true;
|
||||||
settings = {
|
userName = "luochen570";
|
||||||
user = {
|
userEmail = "1160510664@qq.com";
|
||||||
name = "luochen570";
|
extraConfig = {
|
||||||
email = "1160510664@qq.com";
|
|
||||||
};
|
|
||||||
init.defaultBranch = "main";
|
init.defaultBranch = "main";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
10
home/pkg.nix
Normal file
10
home/pkg.nix
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
{ pkgs, ... }:
|
||||||
|
{
|
||||||
|
home.packages = with pkgs;[
|
||||||
|
duf
|
||||||
|
ncdu
|
||||||
|
yazi
|
||||||
|
htop
|
||||||
|
neofetch
|
||||||
|
];
|
||||||
|
}
|
||||||
@@ -2,7 +2,11 @@
|
|||||||
{
|
{
|
||||||
programs.ssh.enable = true;
|
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 =
|
home.file.".ssh/config".source =
|
||||||
config.lib.file.mkOutOfStoreSymlink "/run/secrets/users/luochen570/ssh_config";
|
config.lib.file.mkOutOfStoreSymlink "/run/secrets/users/luochen570/ssh_config";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# 🖥️ hosts 目录说明
|
# 🖥️ hosts 目录说明
|
||||||
|
|
||||||
主机入口层。每台主机目录固定为三文件结构:
|
主机入口层。每台主机目录固定为三文件结构:
|
||||||
- `default.nix`:统一入口,导入 `configuration.nix`
|
- `default.nix`:统一入口,导入 `configuration.nix`
|
||||||
@@ -16,8 +16,12 @@
|
|||||||
│ ├─ 🧩 default.nix
|
│ ├─ 🧩 default.nix
|
||||||
│ ├─ ⚙️ configuration.nix
|
│ ├─ ⚙️ configuration.nix
|
||||||
│ └─ 📝 README.md
|
│ └─ 📝 README.md
|
||||||
└─ 🪟 wsl/
|
└─ 📦 virtualbox/
|
||||||
├─ 🧩 default.nix
|
├─ 🧩 default.nix
|
||||||
├─ ⚙️ configuration.nix
|
├─ ⚙️ configuration.nix
|
||||||
|
├─ 🧱 hardware-configuration.nix
|
||||||
└─ 📝 README.md
|
└─ 📝 README.md
|
||||||
|
|
||||||
```
|
```
|
||||||
|
`r`n
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# 🧑💻 hosts/desktop
|
# 🧑💻 hosts/desktop
|
||||||
|
|
||||||
桌面主机入口。
|
桌面主机入口。
|
||||||
|
|
||||||
@@ -9,3 +9,5 @@
|
|||||||
├─ ⚙️ configuration.nix # profile + hostName + 机器相关配置
|
├─ ⚙️ configuration.nix # profile + hostName + 机器相关配置
|
||||||
└─ 📝 README.md
|
└─ 📝 README.md
|
||||||
```
|
```
|
||||||
|
`r`n
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,30 @@
|
|||||||
{ ... }:
|
{ ... }:
|
||||||
{
|
{
|
||||||
|
# 可在此合并由 nixos-generate-config 生成的机器专属配置:
|
||||||
|
# 磁盘布局、引导加载器、文件系统、硬件选项等。
|
||||||
imports = [
|
imports = [
|
||||||
../../profiles/desktop.nix
|
../../modules/drivers/nvidia.nix
|
||||||
|
../../modules/drivers/amdgpu.nix
|
||||||
];
|
];
|
||||||
|
# Bootloader.
|
||||||
|
boot.loader.systemd-boot.enable = true;
|
||||||
|
boot.loader.efi.canTouchEfiVariables = true;
|
||||||
|
|
||||||
|
|
||||||
|
# Enable CUPS to print documents.
|
||||||
|
# services.printing.enable = true;
|
||||||
|
|
||||||
|
# Enable sound with pipewire.
|
||||||
|
services.pulseaudio.enable = false;
|
||||||
|
security.rtkit.enable = true;
|
||||||
|
services.pipewire = {
|
||||||
|
enable = true;
|
||||||
|
alsa.enable = true;
|
||||||
|
alsa.support32Bit = true;
|
||||||
|
pulse.enable = true;
|
||||||
|
# If you want to use JACK applications, uncomment this
|
||||||
|
#jack.enable = true;
|
||||||
|
};
|
||||||
|
|
||||||
networking.hostName = "desktop";
|
|
||||||
|
|
||||||
# Machine-specific config generated by nixos-generate-config can be
|
|
||||||
# merged here: disk layout, boot loader, filesystem, hardware options.
|
|
||||||
}
|
}
|
||||||
|
|||||||
41
hosts/desktop/hardware-configuration.nix
Normal file
41
hosts/desktop/hardware-configuration.nix
Normal 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
14
hosts/nixos-lxc/README.md
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
# 📦 hosts/nixos-lxc
|
||||||
|
|
||||||
|
Proxmox LXC 主机入口。
|
||||||
|
|
||||||
|
## 🌲 目录树
|
||||||
|
```text
|
||||||
|
hosts/nixos-lxc
|
||||||
|
├─ default.nix
|
||||||
|
├─ configuration.nix
|
||||||
|
└─ README.md
|
||||||
|
```
|
||||||
|
`r`n
|
||||||
|
|
||||||
|
|
||||||
42
hosts/nixos-lxc/configuration.nix
Normal file
42
hosts/nixos-lxc/configuration.nix
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
{ 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.openssh = {
|
||||||
|
enable = true;
|
||||||
|
openFirewall = true;
|
||||||
|
settings = {
|
||||||
|
PermitRootLogin = "yes";
|
||||||
|
PasswordAuthentication = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
security.sudo.wheelNeedsPassword = false;
|
||||||
|
|
||||||
|
services.resolved = {
|
||||||
|
extraConfig = ''
|
||||||
|
Cache=true
|
||||||
|
CacheFromLocalhost=true
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
{ ... }:
|
{ ... }:
|
||||||
|
|
||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
./configuration.nix
|
./configuration.nix
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
# 🗄️ hosts/server
|
# 🗄️ hosts/server
|
||||||
|
|
||||||
服务器主机入口。
|
服务器主机入口。
|
||||||
|
|
||||||
@@ -9,3 +9,5 @@
|
|||||||
├─ ⚙️ configuration.nix # profile + hostName + 机器相关配置
|
├─ ⚙️ configuration.nix # profile + hostName + 机器相关配置
|
||||||
└─ 📝 README.md
|
└─ 📝 README.md
|
||||||
```
|
```
|
||||||
|
`r`n
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,5 @@
|
|||||||
{ ... }:
|
{ ... }:
|
||||||
{
|
{
|
||||||
imports = [
|
# 可在此合并由 nixos-generate-config 生成的机器专属配置:
|
||||||
../../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.
|
|
||||||
}
|
}
|
||||||
|
|||||||
14
hosts/virtualbox/README.md
Normal file
14
hosts/virtualbox/README.md
Normal 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
|
||||||
|
|
||||||
8
hosts/virtualbox/configuration.nix
Normal file
8
hosts/virtualbox/configuration.nix
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
{ ... }:
|
||||||
|
{
|
||||||
|
boot.loader.systemd-boot.enable = true;
|
||||||
|
boot.loader.efi.canTouchEfiVariables = true;
|
||||||
|
|
||||||
|
# 可在此合并由 nixos-generate-config 生成的机器专属配置:
|
||||||
|
# 磁盘布局、引导加载器、文件系统、硬件选项等。
|
||||||
|
}
|
||||||
7
hosts/virtualbox/default.nix
Normal file
7
hosts/virtualbox/default.nix
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
{ ... }:
|
||||||
|
{
|
||||||
|
imports = [
|
||||||
|
./configuration.nix
|
||||||
|
./hardware-configuration.nix
|
||||||
|
];
|
||||||
|
}
|
||||||
29
hosts/virtualbox/hardware-configuration.nix
Normal file
29
hosts/virtualbox/hardware-configuration.nix
Normal 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;
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
# 🪟 hosts/wsl
|
# 🪟 hosts/wsl
|
||||||
|
|
||||||
WSL 主机入口。
|
WSL 主机入口。
|
||||||
|
|
||||||
@@ -9,3 +9,5 @@ WSL 主机入口。
|
|||||||
├─ ⚙️ configuration.nix # profile + hostName(可加 WSL 机器项)
|
├─ ⚙️ configuration.nix # profile + hostName(可加 WSL 机器项)
|
||||||
└─ 📝 README.md
|
└─ 📝 README.md
|
||||||
```
|
```
|
||||||
|
`r`n
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
{ ... }:
|
{ ... }:
|
||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
../../profiles/wsl.nix
|
inputs.nixos-wsl.nixosModules.default
|
||||||
];
|
];
|
||||||
|
|
||||||
networking.hostName = "nixos-wsl";
|
wsl = {
|
||||||
|
enable = true;
|
||||||
# Keep minimal for WSL. Add machine-specific options here if needed.
|
defaultUser = username;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# 🧩 lib 目录说明
|
# 🧩 lib 目录说明
|
||||||
|
|
||||||
公共函数目录。
|
公共函数目录。
|
||||||
|
|
||||||
@@ -8,3 +8,5 @@
|
|||||||
├─ ⚙️ mkHost.nix # 组装 NixOS system 与 Home Manager(接收 username)
|
├─ ⚙️ mkHost.nix # 组装 NixOS system 与 Home Manager(接收 username)
|
||||||
└─ 📋 hosts.nix # 主机清单(system/profile 映射)
|
└─ 📋 hosts.nix # 主机清单(system/profile 映射)
|
||||||
```
|
```
|
||||||
|
`r`n
|
||||||
|
|
||||||
|
|||||||
@@ -2,15 +2,30 @@
|
|||||||
desktop = {
|
desktop = {
|
||||||
system = "x86_64-linux";
|
system = "x86_64-linux";
|
||||||
profile = "desktop";
|
profile = "desktop";
|
||||||
|
hostName = "desktop";
|
||||||
};
|
};
|
||||||
|
|
||||||
server = {
|
server = {
|
||||||
system = "x86_64-linux";
|
system = "x86_64-linux";
|
||||||
profile = "server";
|
profile = "server";
|
||||||
|
hostName = "server";
|
||||||
};
|
};
|
||||||
|
|
||||||
wsl = {
|
wsl = {
|
||||||
system = "x86_64-linux";
|
system = "x86_64-linux";
|
||||||
profile = "wsl";
|
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";
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
{ nixpkgs, home-manager, inputs }:
|
{ nixpkgs, home-manager, inputs }:
|
||||||
{
|
{
|
||||||
hostname,
|
hostname,
|
||||||
|
hostName ? hostname,
|
||||||
|
systemStateVersion ? "25.05",
|
||||||
system,
|
system,
|
||||||
profile,
|
profile,
|
||||||
username,
|
username,
|
||||||
@@ -17,6 +19,10 @@ nixpkgs.lib.nixosSystem {
|
|||||||
inputs.sops-nix.nixosModules.sops
|
inputs.sops-nix.nixosModules.sops
|
||||||
../hosts/${hostname}
|
../hosts/${hostname}
|
||||||
../profiles/${profile}.nix
|
../profiles/${profile}.nix
|
||||||
|
{
|
||||||
|
networking.hostName = hostName;
|
||||||
|
system.stateVersion = systemStateVersion;
|
||||||
|
}
|
||||||
home-manager.nixosModules.home-manager
|
home-manager.nixosModules.home-manager
|
||||||
{
|
{
|
||||||
home-manager.useGlobalPkgs = true;
|
home-manager.useGlobalPkgs = true;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# 🧱 modules 目录说明
|
# 🧱 modules 目录说明
|
||||||
|
|
||||||
系统模块目录。大部分子目录通过 `default.nix` 提供统一入口,驱动目录采用按文件显式引用。
|
系统模块目录。大部分子目录通过 `default.nix` 提供统一入口,驱动目录采用按文件显式引用。
|
||||||
|
|
||||||
@@ -8,6 +8,8 @@
|
|||||||
├─ 🧭 core/ # 全局基础模块
|
├─ 🧭 core/ # 全局基础模块
|
||||||
├─ 🖥️ desktop/ # 桌面模块(DE/WM/应用)
|
├─ 🖥️ desktop/ # 桌面模块(DE/WM/应用)
|
||||||
├─ 🎮 drivers/ # 硬件驱动模块(如 NVIDIA)
|
├─ 🎮 drivers/ # 硬件驱动模块(如 NVIDIA)
|
||||||
├─ 🗄️ server/ # 服务器模块
|
└─ 🗄️ server/ # 服务器模块
|
||||||
└─ 🪟 wsl/ # WSL 模块
|
|
||||||
```
|
```
|
||||||
|
`r`n
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# 🧭 modules/core
|
# 🧭 modules/core
|
||||||
|
|
||||||
所有主机场景都会引入的基础模块。
|
所有主机场景都会引入的基础模块。
|
||||||
|
|
||||||
@@ -6,6 +6,9 @@
|
|||||||
```text
|
```text
|
||||||
🧭 modules/core
|
🧭 modules/core
|
||||||
├─ 🧩 default.nix # 基础 imports + 时区/镜像源/flakes 等默认设置
|
├─ 🧩 default.nix # 基础 imports + 时区/镜像源/flakes 等默认设置
|
||||||
|
├─ 📦 pkg.nix # 全局基础软件包
|
||||||
├─ 👤 users.nix # 用户、默认 shell、密码与公钥
|
├─ 👤 users.nix # 用户、默认 shell、密码与公钥
|
||||||
└─ 🔐 sops.nix # sops-nix secret 映射
|
└─ 🔐 sops.nix # sops-nix secret 映射
|
||||||
```
|
```
|
||||||
|
`r`n
|
||||||
|
|
||||||
|
|||||||
27
modules/core/core.nix
Normal file
27
modules/core/core.nix
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
{ 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";
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,46 +1,9 @@
|
|||||||
{ lib, pkgs, ... }:
|
{ ... }:
|
||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
|
./core.nix
|
||||||
|
./pkg.nix
|
||||||
./users.nix
|
./users.nix
|
||||||
./sops.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";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
11
modules/core/pkg.nix
Normal file
11
modules/core/pkg.nix
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
{ pkgs, ... }:
|
||||||
|
{
|
||||||
|
environment.systemPackages = with pkgs; [
|
||||||
|
curl
|
||||||
|
git
|
||||||
|
htop
|
||||||
|
ranger
|
||||||
|
vim
|
||||||
|
wget
|
||||||
|
];
|
||||||
|
}
|
||||||
@@ -11,6 +11,11 @@ in
|
|||||||
defaultSopsFile = secretFile;
|
defaultSopsFile = secretFile;
|
||||||
secrets = lib.mkIf (builtins.pathExists secretFile) {
|
secrets = lib.mkIf (builtins.pathExists secretFile) {
|
||||||
"users/luochen570/authorized_key" = {};
|
"users/luochen570/authorized_key" = {};
|
||||||
|
"users/luochen570/ssh_private_key" = {
|
||||||
|
owner = "luochen570";
|
||||||
|
group = "users";
|
||||||
|
mode = "0400";
|
||||||
|
};
|
||||||
"users/luochen570/ssh_config" = {
|
"users/luochen570/ssh_config" = {
|
||||||
owner = "luochen570";
|
owner = "luochen570";
|
||||||
group = "users";
|
group = "users";
|
||||||
|
|||||||
@@ -5,19 +5,16 @@
|
|||||||
|
|
||||||
users.users.${username} = {
|
users.users.${username} = {
|
||||||
isNormalUser = true;
|
isNormalUser = true;
|
||||||
extraGroups = [ "wheel" ];
|
extraGroups = [ "wheel" "networkmanager" ];
|
||||||
shell = pkgs.zsh;
|
shell = pkgs.zsh;
|
||||||
};
|
}
|
||||||
|
// lib.optionalAttrs (!(config.sops.secrets ? "users/luochen570/passwordHash")) {
|
||||||
users.users.${username}.initialPassword = lib.mkIf
|
initialPassword = "Dly928730@..";
|
||||||
(!(config.sops.secrets ? "users/luochen570/passwordHash"))
|
}
|
||||||
"Dly928730@..";
|
// lib.optionalAttrs (config.sops.secrets ? "users/luochen570/authorized_key") {
|
||||||
|
openssh.authorizedKeys.keyFiles = [ config.sops.secrets."users/luochen570/authorized_key".path ];
|
||||||
users.users.${username}.openssh.authorizedKeys.keyFiles = lib.mkIf
|
}
|
||||||
(config.sops.secrets ? "users/luochen570/authorized_key")
|
// lib.optionalAttrs (config.sops.secrets ? "users/luochen570/passwordHash") {
|
||||||
[ config.sops.secrets."users/luochen570/authorized_key".path ];
|
hashedPasswordFile = config.sops.secrets."users/luochen570/passwordHash".path;
|
||||||
|
};
|
||||||
users.users.${username}.hashedPasswordFile = lib.mkIf
|
|
||||||
(config.sops.secrets ? "users/luochen570/passwordHash")
|
|
||||||
config.sops.secrets."users/luochen570/passwordHash".path;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,15 @@
|
|||||||
# 🖥️ modules/desktop 目录说明
|
# 🖥️ modules/desktop 目录说明
|
||||||
|
|
||||||
桌面能力模块,按“桌面环境(DE)/窗口管理器(WM)/应用”拆分,便于后续扩展到多种桌面方案。
|
桌面能力模块,按“桌面环境(DE)/窗口管理器(WM)/应用”拆分,便于后续扩展到多种桌面方案。
|
||||||
|
|
||||||
## 🌲 目录树
|
## 🌲 目录树
|
||||||
```text
|
```text
|
||||||
🖥️ modules/desktop
|
🖥️ modules/desktop
|
||||||
├─ 📦 default.nix # 聚合入口(de + apps)
|
├─ 📦 default.nix # 聚合入口(de + pkg + apps)
|
||||||
├─ 🧭 de/ # 桌面环境模块(例如 KDE)
|
├─ 🧭 de/ # 桌面环境模块(例如 KDE)
|
||||||
├─ 🪟 wm/ # 窗口管理器模块(预留)
|
├─ 🪟 wm/ # 窗口管理器模块(预留)
|
||||||
|
├─ 📦 pkg.nix # 桌面软件包
|
||||||
└─ 📱 apps.nix # 桌面应用与默认浏览器关联
|
└─ 📱 apps.nix # 桌面应用与默认浏览器关联
|
||||||
```
|
```
|
||||||
|
`r`n
|
||||||
|
|
||||||
|
|||||||
@@ -1,18 +1,9 @@
|
|||||||
{ pkgs, ... }:
|
{ ... }:
|
||||||
{
|
{
|
||||||
environment.systemPackages = with pkgs; [
|
|
||||||
firefox
|
|
||||||
google-chrome
|
|
||||||
linuxqq
|
|
||||||
wechat-uos
|
|
||||||
xterm
|
|
||||||
kdePackages.kate
|
|
||||||
kdePackages.konsole
|
|
||||||
];
|
|
||||||
|
|
||||||
xdg.mime.enable = true;
|
xdg.mime.enable = true;
|
||||||
xdg.mime.defaultApplications = {
|
xdg.mime.defaultApplications = {
|
||||||
"text/html" = [ "google-chrome.desktop" ];
|
"text/html" = [ "google-chrome.desktop" ];
|
||||||
|
"application/xhtml+xml" = [ "google-chrome.desktop" ];
|
||||||
"x-scheme-handler/http" = [ "google-chrome.desktop" ];
|
"x-scheme-handler/http" = [ "google-chrome.desktop" ];
|
||||||
"x-scheme-handler/https" = [ "google-chrome.desktop" ];
|
"x-scheme-handler/https" = [ "google-chrome.desktop" ];
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# 🧭 modules/desktop/de 目录说明
|
# 🧭 modules/desktop/de 目录说明
|
||||||
|
|
||||||
桌面环境(Desktop Environment)目录。
|
桌面环境(Desktop Environment)目录。
|
||||||
|
|
||||||
@@ -8,3 +8,5 @@
|
|||||||
├─ 📦 default.nix # 聚合入口(当前仅 KDE)
|
├─ 📦 default.nix # 聚合入口(当前仅 KDE)
|
||||||
└─ ⚙️ kde.nix # SDDM + Plasma 6
|
└─ ⚙️ kde.nix # SDDM + Plasma 6
|
||||||
```
|
```
|
||||||
|
`r`n
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,8 @@
|
|||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
./de
|
./de
|
||||||
|
./pkg.nix
|
||||||
./apps.nix
|
./apps.nix
|
||||||
|
./fcitx5.nix
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
20
modules/desktop/fcitx5.nix
Normal file
20
modules/desktop/fcitx5.nix
Normal 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
12
modules/desktop/pkg.nix
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
{ pkgs, ... }:
|
||||||
|
{
|
||||||
|
environment.systemPackages = with pkgs; [
|
||||||
|
firefox
|
||||||
|
google-chrome
|
||||||
|
qq
|
||||||
|
wechat
|
||||||
|
xterm
|
||||||
|
kdePackages.kate
|
||||||
|
kdePackages.konsole
|
||||||
|
];
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
# 🪟 modules/desktop/wm 目录说明
|
# 🪟 modules/desktop/wm 目录说明
|
||||||
|
|
||||||
窗口管理器(Window Manager)目录,当前为预留结构。
|
窗口管理器(Window Manager)目录,当前为预留结构。
|
||||||
|
|
||||||
@@ -7,3 +7,5 @@
|
|||||||
🪟 modules/desktop/wm
|
🪟 modules/desktop/wm
|
||||||
└─ 📦 default.nix # 预留 future imports(hyprland/sway 等)
|
└─ 📦 default.nix # 预留 future imports(hyprland/sway 等)
|
||||||
```
|
```
|
||||||
|
`r`n
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{ ... }:
|
{ ... }:
|
||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
# Future WM modules:
|
# 未来可引入的 WM 模块:
|
||||||
# ./hyprland.nix
|
# ./hyprland.nix
|
||||||
# ./sway.nix
|
# ./sway.nix
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# 🎮 modules/drivers 目录说明
|
# 🎮 modules/drivers 目录说明
|
||||||
|
|
||||||
硬件驱动模块目录,用于集中管理显卡等驱动配置。
|
硬件驱动模块目录,用于集中管理显卡等驱动配置。
|
||||||
|
|
||||||
@@ -9,3 +9,5 @@
|
|||||||
├─ 🔴 amdgpu.nix # AMD iGPU(9700X) 用户态图形/计算支持
|
├─ 🔴 amdgpu.nix # AMD iGPU(9700X) 用户态图形/计算支持
|
||||||
└─ 📝 README.md
|
└─ 📝 README.md
|
||||||
```
|
```
|
||||||
|
`r`n
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
{ pkgs, ... }:
|
{ pkgs, ... }:
|
||||||
{
|
{
|
||||||
# Ryzen 7 9700X iGPU (RDNA2) related userspace support.
|
# Ryzen 7 9700X 核显(RDNA2)相关的用户态支持。
|
||||||
# Keep as a secondary GPU setup; X primary driver is still controlled
|
# 作为辅助显卡配置保留;X 的主显卡驱动仍由
|
||||||
# by the desktop profile / nvidia module.
|
# desktop profile / nvidia 模块控制。
|
||||||
hardware.graphics = {
|
hardware.graphics = {
|
||||||
enable = true;
|
enable = true;
|
||||||
extraPackages = with pkgs; [
|
extraPackages = with pkgs; [
|
||||||
|
|||||||
@@ -7,6 +7,8 @@
|
|||||||
modesetting.enable = true;
|
modesetting.enable = true;
|
||||||
open = true;
|
open = true;
|
||||||
nvidiaSettings = true;
|
nvidiaSettings = true;
|
||||||
|
powerManagement.enable = false;
|
||||||
|
powerManagement.finegrained = false
|
||||||
package = config.boot.kernelPackages.nvidiaPackages.latest;
|
package = config.boot.kernelPackages.nvidiaPackages.latest;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# 🗄️ modules/server
|
# 🗄️ modules/server
|
||||||
|
|
||||||
服务器专用模块。
|
服务器专用模块。
|
||||||
|
|
||||||
@@ -6,6 +6,11 @@
|
|||||||
```text
|
```text
|
||||||
🗄️ modules/server
|
🗄️ modules/server
|
||||||
├─ 📦 default.nix # 聚合入口
|
├─ 📦 default.nix # 聚合入口
|
||||||
|
├─ 📦 pkg.nix # 服务器常用软件包
|
||||||
|
├─ 🔥 firewall.nix # 防火墙默认策略
|
||||||
├─ 🔐 ssh.nix # OpenSSH 参数
|
├─ 🔐 ssh.nix # OpenSSH 参数
|
||||||
└─ 🐳 docker.nix # Docker 与清理策略
|
├─ 🐳 docker.nix # Docker 与清理策略
|
||||||
|
├─ 📦 virtualbox-guest.nix # VirtualBox Guest 增强配置
|
||||||
|
└─ 🧠 vscode-server.nix # VS Code Server 模块
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
{ ... }:
|
{ ... }:
|
||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
|
./pkg.nix
|
||||||
|
./firewall.nix
|
||||||
./docker.nix
|
./docker.nix
|
||||||
./ssh.nix
|
./ssh.nix
|
||||||
];
|
];
|
||||||
|
|||||||
4
modules/server/firewall.nix
Normal file
4
modules/server/firewall.nix
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
{ lib, ... }:
|
||||||
|
{
|
||||||
|
networking.firewall.enable = lib.mkDefault true;
|
||||||
|
}
|
||||||
6
modules/server/pkg.nix
Normal file
6
modules/server/pkg.nix
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
{ pkgs, ... }:
|
||||||
|
{
|
||||||
|
environment.systemPackages = with pkgs; [
|
||||||
|
|
||||||
|
];
|
||||||
|
}
|
||||||
@@ -2,13 +2,13 @@
|
|||||||
{
|
{
|
||||||
services.openssh = {
|
services.openssh = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
openFirewall = true;
|
||||||
settings = {
|
settings = {
|
||||||
PasswordAuthentication = false;
|
PasswordAuthentication = false;
|
||||||
KbdInteractiveAuthentication = false;
|
KbdInteractiveAuthentication = false;
|
||||||
PermitRootLogin = "no";
|
PermitRootLogin = "no";
|
||||||
X11Forwarding = false;
|
X11Forwarding = false;
|
||||||
};
|
};
|
||||||
openFirewall = true;
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
6
modules/server/virtualbox-guest.nix
Normal file
6
modules/server/virtualbox-guest.nix
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
{ ... }:
|
||||||
|
{
|
||||||
|
# VirtualBox Guest 增强支持
|
||||||
|
virtualisation.virtualbox.guest.enable = true;
|
||||||
|
virtualisation.virtualbox.guest.dragAndDrop = true;
|
||||||
|
}
|
||||||
13
modules/server/vscode-server.nix
Normal file
13
modules/server/vscode-server.nix
Normal 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;
|
||||||
|
}
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
# 🪟 modules/wsl
|
|
||||||
|
|
||||||
WSL 集成模块。
|
|
||||||
|
|
||||||
## 🌲 目录树
|
|
||||||
```text
|
|
||||||
🪟 modules/wsl
|
|
||||||
├─ 📦 default.nix # 聚合入口
|
|
||||||
├─ ⚙️ configuration.nix # WSL 配置实现
|
|
||||||
└─ 📝 README.md
|
|
||||||
```
|
|
||||||
@@ -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" ];
|
|
||||||
}
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
# 🎨 overlays 目录说明
|
# 🎨 overlays 目录说明
|
||||||
|
|
||||||
`nixpkgs` 包覆盖目录。
|
`nixpkgs` 包覆盖目录。
|
||||||
|
|
||||||
@@ -7,3 +7,5 @@
|
|||||||
🎨 overlays
|
🎨 overlays
|
||||||
└─ (自定义 overlay 文件)
|
└─ (自定义 overlay 文件)
|
||||||
```
|
```
|
||||||
|
`r`n
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# 📚 profiles 目录说明
|
# 📚 profiles 目录说明
|
||||||
|
|
||||||
场景化组合层,负责选择 `modules/*`。
|
场景化组合层,负责选择 `modules/*`。
|
||||||
|
|
||||||
@@ -7,5 +7,9 @@
|
|||||||
📚 profiles
|
📚 profiles
|
||||||
├─ 🧑💻 desktop.nix # core + desktop + drivers
|
├─ 🧑💻 desktop.nix # core + desktop + drivers
|
||||||
├─ 🗄️ server.nix # core + server(default.nix)
|
├─ 🗄️ 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
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,5 @@
|
|||||||
imports = [
|
imports = [
|
||||||
../modules/core
|
../modules/core
|
||||||
../modules/desktop
|
../modules/desktop
|
||||||
../modules/drivers/nvidia.nix
|
|
||||||
../modules/drivers/amdgpu.nix
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
6
profiles/lxc.nix
Normal file
6
profiles/lxc.nix
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
{ ... }:
|
||||||
|
{
|
||||||
|
imports = [
|
||||||
|
../modules/core
|
||||||
|
];
|
||||||
|
}
|
||||||
10
profiles/virtualbox.nix
Normal file
10
profiles/virtualbox.nix
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
{ ... }:
|
||||||
|
{
|
||||||
|
imports = [
|
||||||
|
../modules/core
|
||||||
|
../modules/desktop
|
||||||
|
../modules/server/ssh.nix
|
||||||
|
../modules/server/virtualbox-guest.nix
|
||||||
|
../modules/server/vscode-server.nix
|
||||||
|
];
|
||||||
|
}
|
||||||
@@ -2,9 +2,8 @@
|
|||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
../modules/core
|
../modules/core
|
||||||
../modules/wsl
|
../modules/server/ssh.nix
|
||||||
|
../modules/server/vscode-server.nix
|
||||||
];
|
];
|
||||||
|
|
||||||
networking.firewall.enable = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# 🔐 secrets 目录说明
|
# 🔐 secrets 目录说明
|
||||||
|
|
||||||
`sops-nix` 密钥目录。
|
`sops-nix` 密钥目录。
|
||||||
|
|
||||||
@@ -11,3 +11,5 @@
|
|||||||
建议:
|
建议:
|
||||||
- 仅提交加密后的 `*.enc.yaml`
|
- 仅提交加密后的 `*.enc.yaml`
|
||||||
- 明文仅保留 `*.example` 模板
|
- 明文仅保留 `*.example` 模板
|
||||||
|
`r`n
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# 👤 secrets/users 目录说明
|
# 👤 secrets/users 目录说明
|
||||||
|
|
||||||
用户级 secret 模板与密文。
|
用户级 secret 模板与密文。
|
||||||
|
|
||||||
@@ -12,3 +12,6 @@
|
|||||||
## 🔐 本地源文件(Git 黑名单)
|
## 🔐 本地源文件(Git 黑名单)
|
||||||
- 你可以在本目录维护 `*.source` 文件作为本地敏感源文件(例如真实域名和 IP)。
|
- 你可以在本目录维护 `*.source` 文件作为本地敏感源文件(例如真实域名和 IP)。
|
||||||
- 这些文件已被仓库 `.gitignore` 屏蔽,不会被 Git 收集和推送。
|
- 这些文件已被仓库 `.gitignore` 屏蔽,不会被 Git 收集和推送。
|
||||||
|
- 示例:`luochen570.ssh_config.source`、`luochen570.id_rsa.source`
|
||||||
|
`r`n
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,10 @@
|
|||||||
users:
|
users:
|
||||||
luochen570:
|
luochen570:
|
||||||
authorized_key: "ssh-rsa AAAA... your-comment"
|
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"
|
passwordHash: "REPLACE_WITH_mkpasswd_HASH"
|
||||||
ssh_config: |
|
ssh_config: |
|
||||||
# ~/.ssh/config
|
# ~/.ssh/config
|
||||||
|
|||||||
Reference in New Issue
Block a user