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
This commit is contained in:
luochen570
2026-02-28 10:21:32 +08:00
parent 620b587010
commit 3659dc3e50
33 changed files with 312 additions and 165 deletions

View File

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

View File

@@ -1,6 +1,6 @@
{ {
description = "My Infra"; description = "My Infra";
inputs = { inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.05"; nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.05";
@@ -8,12 +8,12 @@
url = "github:nix-community/home-manager/release-25.05"; url = "github:nix-community/home-manager/release-25.05";
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs";
}; };
nix4nvchad = { nix4nvchad = {
url = "github:nix-community/nix4nvchad"; url = "github:nix-community/nix4nvchad";
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs";
}; };
nixos-wsl.url = "github:nix-community/NixOS-WSL/main"; nixos-wsl.url = "github:nix-community/NixOS-WSL/main";
vscode-server.url = "github:nix-community/nixos-vscode-server"; vscode-server.url = "github:nix-community/nixos-vscode-server";
@@ -23,7 +23,7 @@
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs";
}; };
}; };
outputs = inputs@{ nixpkgs, home-manager, ... }: outputs = inputs@{ nixpkgs, home-manager, ... }:
let let
username = "luochen570"; username = "luochen570";

View File

@@ -6,8 +6,8 @@
user = { user = {
name = "luochen570"; name = "luochen570";
email = "1160510664@qq.com"; email = "1160510664@qq.com";
}; };
init.defaultBranch = "main"; init.defaultBranch = "main";
}; };
}; };
} }

View File

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

View File

@@ -2,6 +2,10 @@
{ {
programs.ssh.enable = true; programs.ssh.enable = true;
# ~/.ssh/id_rsa comes from a sops secret file.
home.file.".ssh/id_rsa".source =
config.lib.file.mkOutOfStoreSymlink "/run/secrets/users/luochen570/ssh_private_key";
# ~/.ssh/config comes from a sops secret file. # ~/.ssh/config comes from a sops secret file.
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";

View File

@@ -1,61 +1,61 @@
{ config, pkgs, inputs, system, ... }: { config, pkgs, inputs, system, ... }:
{ programs.zsh = { { programs.zsh = {
enable = true; enable = true;
enableCompletion = true; enableCompletion = true;
autosuggestion.enable = true; autosuggestion.enable = true;
syntaxHighlighting.enable = true; syntaxHighlighting.enable = true;
# initContent = "source ~/.p10k.zsh"; # initContent = "source ~/.p10k.zsh";
plugins = [ plugins = [
{ {
name = "powerlevel10k"; name = "powerlevel10k";
src = pkgs.zsh-powerlevel10k; src = pkgs.zsh-powerlevel10k;
file = "share/zsh-powerlevel10k/powerlevel10k.zsh-theme"; file = "share/zsh-powerlevel10k/powerlevel10k.zsh-theme";
} }
{ {
name = "fzf-tab"; name = "fzf-tab";
src = "${pkgs.zsh-fzf-tab}/share/fzf-tab"; src = "${pkgs.zsh-fzf-tab}/share/fzf-tab";
} }
# { # {
# name = "powerlevel10k-config"; # name = "powerlevel10k-config";
# src = "/home/luochen570/nixos-config/modules/home/p10k/"; # src = "/home/luochen570/nixos-config/modules/home/p10k/";
# file = "p10k.zsh"; # file = "p10k.zsh";
# } # }
]; ];
# 设置alias # 设置alias
shellAliases = { shellAliases = {
# Git相关 # Git相关
gc1 = "git clone --recursive --depth=1"; gc1 = "git clone --recursive --depth=1";
# 目录操作 # 目录操作
md = "mkdir -p"; md = "mkdir -p";
"..." = "../.."; "..." = "../..";
"...." = "../../.."; "...." = "../../..";
"....." = "../../../.."; "....." = "../../../..";
"......" = "../../../../.."; "......" = "../../../../..";
# eza/ls替代 # eza/ls替代
ls = "eza --color=auto"; ls = "eza --color=auto";
l = "eza -lbah --icons=auto"; l = "eza -lbah --icons=auto";
la = "eza -labgh --icons=auto"; la = "eza -labgh --icons=auto";
ll = "eza -lbg --icons=auto"; ll = "eza -lbg --icons=auto";
lt = "eza -lTbg --icons=auto"; lt = "eza -lTbg --icons=auto";
lsa = "eza -lbagR --icons=auto"; lsa = "eza -lbagR --icons=auto";
lst = "eza -lTabgh --icons=auto"; lst = "eza -lTabgh --icons=auto";
# bat/cat替代 # bat/cat替代
cat = "bat -pp"; cat = "bat -pp";
ccat = "cat"; ccat = "cat";
}; };
oh-my-zsh = { oh-my-zsh = {
enable = true; enable = true;
plugins = [ plugins = [
"sudo" "sudo"
"z" "z"
"extract" "extract"
"git" "git"
# "fzf-tab" # "fzf-tab"
]; ];
}; };
}; };
} }

View File

@@ -0,0 +1,11 @@
# hosts/virtualbox
VirtualBox guest host entry.
## Layout
```text
hosts/virtualbox
|- default.nix # host entry, imports configuration.nix
|- configuration.nix # profile + hostName + machine specific options
`- README.md
```

View File

@@ -0,0 +1,11 @@
{ ... }:
{
imports = [
../../profiles/virtualbox.nix
];
networking.hostName = "virtualbox";
# Machine-specific config generated by nixos-generate-config can be
# merged here: disk layout, boot loader, filesystem, hardware options.
}

View File

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

View File

@@ -0,0 +1,29 @@
# 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 = [ ];
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

@@ -13,4 +13,9 @@
system = "x86_64-linux"; system = "x86_64-linux";
profile = "wsl"; profile = "wsl";
}; };
}
virtualbox = {
system = "x86_64-linux";
profile = "virtualbox";
};
}

View File

@@ -6,6 +6,7 @@
```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 映射
``` ```

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";
networking.firewall.enable = lib.mkDefault true;
system.stateVersion = lib.mkDefault "25.05";
}

View File

@@ -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";
}

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

@@ -0,0 +1,12 @@
{ pkgs, ... }:
{
environment.systemPackages = with pkgs; [
curl
eza
git
htop
ranger
vim
wget
];
}

View File

@@ -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";

View File

@@ -5,8 +5,9 @@
## 🌲 目录树 ## 🌲 目录树
```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 # 桌面应用与默认浏览器关联
``` ```

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.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" ];
}; };
} }

View File

@@ -2,6 +2,8 @@
{ {
imports = [ imports = [
./de ./de
./pkg.nix
./apps.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
linuxqq
wechat-uos
xterm
kdePackages.kate
kdePackages.konsole
];
}

View File

@@ -5,7 +5,9 @@
## 🌲 目录树 ## 🌲 目录树
```text ```text
🗄️ modules/server 🗄️ modules/server
├─ 📦 default.nix # 聚合入口 ├─ 📦 default.nix # 聚合入口
├─ 🔐 ssh.nix # OpenSSH 参数 ├─ 📦 pkg.nix # 服务器常用软件包
🐳 docker.nix # Docker 与清理策略 🔐 ssh.nix # OpenSSH 参数
├─ 🐳 docker.nix # Docker 与清理策略
└─ 🧠 vscode-server.nix # VS Code Server 模块
``` ```

View File

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

View File

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

6
modules/server/pkg.nix Normal file
View File

@@ -0,0 +1,6 @@
{ pkgs, ... }:
{
environment.systemPackages = with pkgs; [
jq
];
}

View File

@@ -10,5 +10,5 @@
}; };
openFirewall = true; openFirewall = true;
}; };
} }

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

@@ -2,7 +2,7 @@
{ {
imports = [ imports = [
inputs.nixos-wsl.nixosModules.default inputs.nixos-wsl.nixosModules.default
inputs.vscode-server.nixosModules.default ../server/vscode-server.nix
]; ];
wsl = { wsl = {
@@ -10,6 +10,5 @@
defaultUser = username; defaultUser = username;
}; };
services.vscode-server.enable = true;
users.users.${username}.extraGroups = [ "vscode" "docker" "wheel" ]; users.users.${username}.extraGroups = [ "vscode" "docker" "wheel" ];
} }

10
profiles/virtualbox.nix Normal file
View File

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

View File

@@ -3,6 +3,7 @@
imports = [ imports = [
../modules/core ../modules/core
../modules/wsl ../modules/wsl
../modules/server/ssh.nix
]; ];
networking.firewall.enable = false; networking.firewall.enable = false;

View File

@@ -12,3 +12,4 @@
## 🔐 本地源文件Git 黑名单) ## 🔐 本地源文件Git 黑名单)
- 你可以在本目录维护 `*.source` 文件作为本地敏感源文件(例如真实域名和 IP - 你可以在本目录维护 `*.source` 文件作为本地敏感源文件(例如真实域名和 IP
- 这些文件已被仓库 `.gitignore` 屏蔽,不会被 Git 收集和推送。 - 这些文件已被仓库 `.gitignore` 屏蔽,不会被 Git 收集和推送。
- 示例:`luochen570.ssh_config.source``luochen570.id_rsa.source`

View File

@@ -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