refactor(modules): 提取 ZshModule 并将所有模块移入 modules/ 包

This commit is contained in:
2026-03-26 14:26:07 +08:00
parent f6c0c8791b
commit 6ea16d27e1
6 changed files with 44 additions and 22 deletions
View File
+38
View File
@@ -0,0 +1,38 @@
import decman
from decman import File, Module
from decman.plugins.aur import packages as aur_packages
from decman.plugins.pacman import packages as pacman_packages
class ZshModule(Module):
def __init__(self, user: str):
super().__init__("zsh")
self.user = user
def files(self):
return {
f"/home/{self.user}/.zshrc": File(
source_file="./home/.zshrc",
owner=self.user,
),
}
@pacman_packages
def pacman_packages(self) -> set[str]:
return {
"fzf",
"zsh",
"zsh-autosuggestions",
"zsh-completions",
"zsh-syntax-highlighting",
}
@aur_packages
def aur_packages(self) -> set[str]:
return {
"fzf-tab-git",
"oh-my-zsh-git",
}
def on_enable(self, store):
decman.prg(["chsh", "-s", "/usr/bin/zsh", self.user])
-5
View File
@@ -37,11 +37,6 @@ yay -S --needed --noconfirm decman
echo "==> 应用系统配置..."
sudo decman --source "$CONFIG_DIR/source.py" < /dev/tty
echo "==> 设置默认 shell 为 zsh..."
if [ "$SHELL" != "$(which zsh)" ]; then
sudo chsh -s "$(which zsh)" "$USER"
fi
echo ""
echo "✓ 安装完成!重新登录以使用 zsh。"
echo ""
+6 -17
View File
@@ -12,8 +12,9 @@ import os
import decman
from decman import File
import docker_module
import locale_module
import modules.docker
import modules.locale
import modules.zsh
assert decman.pacman is not None
assert decman.aur is not None
@@ -35,16 +36,11 @@ decman.files["/etc/sudoers.d/10-wheel"] = File(
permissions=0o440,
)
# ── 用户配置 ─────────────────────────────────────────────────
decman.files[f"{HOME}/.zshrc"] = File(
source_file="./home/.zshrc",
owner=USERNAME,
)
# ── Modules ──────────────────────────────────────────────────
decman.modules += [
locale_module.LocaleModule(),
docker_module.DockerModule(),
modules.locale.LocaleModule(),
modules.docker.DockerModule(),
modules.zsh.ZshModule(USERNAME),
]
# ── Pacman 包(官方仓库)──────────────────────────────────────
@@ -54,7 +50,6 @@ decman.pacman.packages |= {
"bun",
"curl",
"fd",
"fzf",
"git",
"mise",
"neovim",
@@ -65,16 +60,10 @@ decman.pacman.packages |= {
"vim",
"wget",
"zoxide",
"zsh",
"zsh-autosuggestions",
"zsh-completions",
"zsh-syntax-highlighting",
}
# ── AUR 包 ────────────────────────────────────────────────────
decman.aur.packages |= {
"decman",
"fzf-tab-git",
"oh-my-zsh-git",
"yay",
}