new file: .gitignore

new file:   .sops.yaml
	new file:   README.md
	modified:   flake.nix
	new file:   home/README.md
	new file:   home/default.nix
	modified:   home/git.nix
	new file:   home/ssh.nix
	new file:   hosts/README.md
	new file:   hosts/desktop/README.md
	new file:   hosts/desktop/configuration.nix
	new file:   hosts/desktop/default.nix
	new file:   hosts/server/README.md
	new file:   hosts/server/configuration.nix
	modified:   hosts/server/default.nix
	new file:   hosts/wsl/README.md
	new file:   hosts/wsl/configuration.nix
	new file:   hosts/wsl/default.nix
	new file:   lib/README.md
	new file:   lib/hosts.nix
	modified:   lib/mkHost.nix
	new file:   modules/README.md
	new file:   modules/core/README.md
	new file:   modules/core/default.nix
	new file:   modules/core/sops.nix
	new file:   modules/core/users.nix
	new file:   modules/desktop/README.md
	new file:   modules/desktop/apps.nix
	new file:   modules/desktop/de/README.md
	new file:   modules/desktop/de/default.nix
	new file:   modules/desktop/de/kde.nix
	new file:   modules/desktop/default.nix
	new file:   modules/desktop/wm/README.md
	new file:   modules/desktop/wm/default.nix
	new file:   modules/drivers/README.md
	new file:   modules/drivers/amdgpu.nix
	new file:   modules/drivers/nvidia.nix
	new file:   modules/server/README.md
	new file:   modules/server/default.nix
	new file:   modules/server/docker.nix
	new file:   modules/server/ssh.nix
	new file:   modules/wsl/README.md
	new file:   modules/wsl/configuration.nix
	new file:   modules/wsl/default.nix
	deleted:    modules/wsl/wsl.nix
	new file:   overlays/README.md
	new file:   profiles/README.md
	new file:   profiles/desktop.nix
	modified:   profiles/server.nix
	new file:   profiles/wsl.nix
	new file:   secrets/README.md
	new file:   secrets/users/README.md
	new file:   secrets/users/luochen570.enc.yaml.example
添加了一些文件并优化了了部分配置
桌面驱动有待改进等我去nixos实际操作一下改进
该配置纯gpt生产,可能存在一些问题,欢迎大家提出意见和建议
未经任何测试,直接提交了,请勿直接使用
This commit is contained in:
luochen570
2026-02-27 23:58:08 +08:00
parent 611d7c1c1f
commit 620b587010
53 changed files with 733 additions and 45 deletions

13
modules/README.md Normal file
View File

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

11
modules/core/README.md Normal file
View File

@@ -0,0 +1,11 @@
# 🧭 modules/core
所有主机场景都会引入的基础模块。
## 🌲 目录树
```text
🧭 modules/core
├─ 🧩 default.nix # 基础 imports + 时区/镜像源/flakes 等默认设置
├─ 👤 users.nix # 用户、默认 shell、密码与公钥
└─ 🔐 sops.nix # sops-nix secret 映射
```

46
modules/core/default.nix Normal file
View File

@@ -0,0 +1,46 @@
{ lib, pkgs, ... }:
{
imports = [
./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";
}

24
modules/core/sops.nix Normal file
View File

@@ -0,0 +1,24 @@
{ lib, ... }:
let
secretFile = ../../secrets/users/luochen570.enc.yaml;
in
{
sops = {
age = {
keyFile = "/var/lib/sops-nix/key.txt";
generateKey = true;
};
defaultSopsFile = secretFile;
secrets = lib.mkIf (builtins.pathExists secretFile) {
"users/luochen570/authorized_key" = {};
"users/luochen570/ssh_config" = {
owner = "luochen570";
group = "users";
mode = "0600";
};
"users/luochen570/passwordHash" = {
neededForUsers = true;
};
};
};
}

23
modules/core/users.nix Normal file
View File

@@ -0,0 +1,23 @@
{ lib, pkgs, username, config, ... }:
{
programs.zsh.enable = true;
users.defaultUserShell = pkgs.zsh;
users.users.${username} = {
isNormalUser = true;
extraGroups = [ "wheel" ];
shell = pkgs.zsh;
};
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;
}

12
modules/desktop/README.md Normal file
View File

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

19
modules/desktop/apps.nix Normal file
View File

@@ -0,0 +1,19 @@
{ 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" ];
"x-scheme-handler/http" = [ "google-chrome.desktop" ];
"x-scheme-handler/https" = [ "google-chrome.desktop" ];
};
}

View File

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

View File

@@ -0,0 +1,6 @@
{ ... }:
{
imports = [
./kde.nix
];
}

View File

@@ -0,0 +1,6 @@
{ ... }:
{
services.xserver.enable = true;
services.displayManager.sddm.enable = true;
services.desktopManager.plasma6.enable = true;
}

View File

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

View File

@@ -0,0 +1,9 @@
# 🪟 modules/desktop/wm 目录说明
窗口管理器Window Manager目录当前为预留结构。
## 🌲 目录树
```text
🪟 modules/desktop/wm
└─ 📦 default.nix # 预留 future importshyprland/sway 等)
```

View File

@@ -0,0 +1,8 @@
{ ... }:
{
imports = [
# Future WM modules:
# ./hyprland.nix
# ./sway.nix
];
}

11
modules/drivers/README.md Normal file
View File

@@ -0,0 +1,11 @@
# 🎮 modules/drivers 目录说明
硬件驱动模块目录,用于集中管理显卡等驱动配置。
## 🌲 目录树
```text
🎮 modules/drivers
├─ 🟢 nvidia.nix # NVIDIA 驱动配置与双显卡备用说明
├─ 🔴 amdgpu.nix # AMD iGPU(9700X) 用户态图形/计算支持
└─ 📝 README.md
```

View File

@@ -0,0 +1,16 @@
{ 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.
hardware.graphics = {
enable = true;
extraPackages = with pkgs; [
amdvlk
rocmPackages.clr.icd
];
extraPackages32 = with pkgs; [
driversi686Linux.amdvlk
];
};
}

View File

@@ -0,0 +1,43 @@
{ config, ... }:
{
services.xserver.videoDrivers = [ "nvidia" ];
hardware.graphics.enable = true;
hardware.nvidia = {
modesetting.enable = true;
open = true;
nvidiaSettings = true;
package = config.boot.kernelPackages.nvidiaPackages.latest;
};
# 备用方案(当前禁用):
# 如果后续要启用 AMD 核显 + NVIDIA 独显切换,请取消下面整段注释。
#
# 重要提醒:
# 1) 先确认两张显卡的 PCIe Bus ID再启用否则图形界面可能无法启动。
# 2) 获取命令lspci | grep -E "VGA|3D"
# 3) 示例输出常见为 "01:00.0"、"06:00.0"16 进制)。
# 4) Nix 配置常用写法PCI:<bus-dec>:<device-dec>:<function>
# 例如 01:00.0 -> PCI:1:0:006:00.0 -> PCI:6:0:0
#
# let
# amdgpuBusId = "PCI:6:0:0";
# nvidiaBusId = "PCI:1:0:0";
# in {
# services.xserver.videoDrivers = [ "amdgpu" "nvidia" ];
# hardware.nvidia.prime = {
# offload.enable = true;
# offload.enableOffloadCmd = true;
# amdgpuBusId = amdgpuBusId;
# nvidiaBusId = nvidiaBusId;
# };
# specialisation.nvidia-sync.configuration = {
# hardware.nvidia.prime = {
# offload.enable = lib.mkForce false;
# sync.enable = true;
# amdgpuBusId = amdgpuBusId;
# nvidiaBusId = nvidiaBusId;
# };
# };
# }
}

11
modules/server/README.md Normal file
View File

@@ -0,0 +1,11 @@
# 🗄️ modules/server
服务器专用模块。
## 🌲 目录树
```text
🗄️ modules/server
├─ 📦 default.nix # 聚合入口
├─ 🔐 ssh.nix # OpenSSH 参数
└─ 🐳 docker.nix # Docker 与清理策略
```

View File

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

11
modules/server/docker.nix Normal file
View File

@@ -0,0 +1,11 @@
{ ... }:
{
virtualisation.docker = {
enable = true;
autoPrune = {
enable = true;
dates = "weekly";
};
};
}

14
modules/server/ssh.nix Normal file
View File

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

11
modules/wsl/README.md Normal file
View File

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

View File

@@ -0,0 +1,15 @@
{ 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" ];
}

6
modules/wsl/default.nix Normal file
View File

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

View File