refactor(locale): 提取 locale 配置为 decman Module
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
import decman
|
||||
from decman import File, Module
|
||||
|
||||
|
||||
class LocaleModule(Module):
|
||||
def __init__(self):
|
||||
super().__init__("locale")
|
||||
|
||||
def files(self):
|
||||
return {
|
||||
"/etc/locale.conf": File(content="LANG=en_US.UTF-8\n"),
|
||||
"/etc/locale.gen": File(content="en_US.UTF-8 UTF-8\n"),
|
||||
}
|
||||
|
||||
def on_change(self, store):
|
||||
decman.prg(["locale-gen"])
|
||||
@@ -37,9 +37,6 @@ yay -S --needed --noconfirm decman
|
||||
echo "==> 应用系统配置..."
|
||||
sudo decman --source "$CONFIG_DIR/source.py"
|
||||
|
||||
echo "==> 生成 locale..."
|
||||
sudo locale-gen
|
||||
|
||||
echo "==> 设置默认 shell 为 zsh..."
|
||||
if [ "$SHELL" != "$(which zsh)" ]; then
|
||||
sudo chsh -s "$(which zsh)" "$USER"
|
||||
|
||||
@@ -11,6 +11,8 @@ import os
|
||||
import decman
|
||||
from decman import File
|
||||
|
||||
import locale_module
|
||||
|
||||
assert decman.pacman is not None
|
||||
assert decman.aur is not None
|
||||
|
||||
@@ -43,14 +45,12 @@ decman.pacman.packages |= {
|
||||
|
||||
# ── AUR 包 ────────────────────────────────────────────────────
|
||||
decman.aur.packages |= {
|
||||
"decman",
|
||||
"yay",
|
||||
# 开发工具
|
||||
"bun",
|
||||
"mise",
|
||||
# Zsh 插件
|
||||
"decman",
|
||||
"fzf-tab-git",
|
||||
"mise",
|
||||
"oh-my-zsh-git",
|
||||
"yay",
|
||||
}
|
||||
|
||||
# ── 系统文件(/etc/)──────────────────────────────────────────
|
||||
@@ -63,10 +63,7 @@ decman.files["/etc/sudoers.d/10-wheel"] = File(
|
||||
permissions=0o440,
|
||||
)
|
||||
|
||||
decman.files["/etc/locale.conf"] = File(content="LANG=en_US.UTF-8\n")
|
||||
|
||||
# 仅保留需要的 locale;修改后需手动执行 locale-gen
|
||||
decman.files["/etc/locale.gen"] = File(content="en_US.UTF-8 UTF-8\n")
|
||||
decman.modules += [locale_module.LocaleModule()]
|
||||
|
||||
# ── 用户配置 ─────────────────────────────────────────────────
|
||||
decman.files[f"{HOME}/.zshrc"] = File(
|
||||
|
||||
Reference in New Issue
Block a user