diff --git a/modules/__init__.py b/modules/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/docker_module.py b/modules/docker.py similarity index 100% rename from docker_module.py rename to modules/docker.py diff --git a/locale_module.py b/modules/locale.py similarity index 100% rename from locale_module.py rename to modules/locale.py diff --git a/modules/zsh.py b/modules/zsh.py new file mode 100644 index 0000000..9153e6d --- /dev/null +++ b/modules/zsh.py @@ -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]) diff --git a/scripts/install.sh b/scripts/install.sh index bf4daeb..a94ae24 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -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 "" diff --git a/source.py b/source.py index 8fa58d0..2843be2 100644 --- a/source.py +++ b/source.py @@ -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", }