chezmoi 建立unRoot執行框架(執行內容尚未實做)

This commit is contained in:
Yuan Chiu 2025-05-04 15:58:37 +08:00
parent d9d8b00cb5
commit d62459930e
3 changed files with 22 additions and 7 deletions

View File

@ -1,21 +1,27 @@
{{- $name := promptStringOnce . "name" "請輸入您的姓名" -}} {{- $name := promptStringOnce . "name" "請輸入您的姓名" -}}
{{- $email := promptStringOnce . "email" "輸入您的Email地址" -}} {{- $email := promptStringOnce . "email" "輸入您的Email地址" -}}
{{- $hosttype_choices := list "desktop" "server" "manual" -}} {{- $hosttype_choices := list "desktop" "server" "unroot_server" "manual" -}}
{{- $hosttype := promptChoice "What type of host are you on" $hosttype_choices -}} {{- $hosttype := promptChoice "What type of host are you on" $hosttype_choices -}}
{{- $isServer := true -}} {{- $isServer := true -}}
{{- $unRootMode := true -}}
{{- $enableSixel := false -}} {{- $enableSixel := false -}}
{{- $enableGUI := false -}} {{- $enableGUI := false -}}
{{- $enableYcm := false -}} {{- $enableYcm := false -}}
{{- if eq $hosttype "desktop" -}} {{- if eq $hosttype "server" -}}
{{- $unRootMode = false -}}
{{- else if eq $hosttype "desktop" -}}
{{- $isServer = false -}} {{- $isServer = false -}}
{{- $unRootMode = false -}}
{{- $enableSixel = true -}} {{- $enableSixel = true -}}
{{- $enableGUI = true -}} {{- $enableGUI = true -}}
{{- $enableYcm = true -}} {{- $enableYcm = true -}}
{{- else if eq $hosttype "manual" -}} {{- else if eq $hosttype "manual" -}}
{{- $isServer = promptBool "Does this machine is Server" -}} {{- $isServer = promptBool "Does this machine is Server" -}}
{{- $unRootMode = promptBool "Is enable unRoot local mode (Will install at home directory)" -}}
{{- $enableSixel = promptBool "Is enable terminal output with sixel" -}} {{- $enableSixel = promptBool "Is enable terminal output with sixel" -}}
{{- $enableGUI = promptBool "Does this machine have a GUI" -}} {{- $enableGUI = promptBool "Does this machine have a GUI" -}}
{{- $enableYcm = promptBool "Is enable Vim YCM compatible (Will use 2.7GB)" -}} {{- $enableYcm = promptBool "Is enable Vim YCM compatible (Will use 2.7GB)" -}}
@ -27,6 +33,7 @@ sourceDir = "~/.local/share/chezmoi"
name = {{ $name | quote }} name = {{ $name | quote }}
email = {{ $email | quote }} email = {{ $email | quote }}
serverStyle = {{ $isServer }} serverStyle = {{ $isServer }}
unRootMode = {{ $unRootMode }}
enableSixel = {{ $enableSixel }} {{/* TODO: packages.toml還沒處理 */}} enableSixel = {{ $enableSixel }} {{/* TODO: packages.toml還沒處理 */}}
noGUI = {{ not $enableGUI }} noGUI = {{ not $enableGUI }}
enableYcm = {{ $enableYcm }} enableYcm = {{ $enableYcm }}

View File

@ -1,4 +1,4 @@
{{ if eq .chezmoi.os "darwin" -}} {{ if and (not .unRootMode) (eq .chezmoi.os "darwin") -}}
#!/bin/sh #!/bin/sh
# Install Homebrew # Install Homebrew

View File

@ -1,5 +1,11 @@
{{ if eq .chezmoi.os "linux" -}} {{ if eq .chezmoi.os "linux" -}}
{{/* ---- 安裝腳本 ------------------------------------------------------- */ -}}
{{/* **** unRoot Mode *************************************************** */ -}}
{{ if .unRootMode -}}
{{/* **** Root Mode ***************************************************** */ -}}
{{ else -}}
#!/bin/bash #!/bin/bash
{{/* ==== Debian ======================================================== */ -}} {{/* ==== Debian ======================================================== */ -}}
@ -57,7 +63,7 @@ fi
rm -rf lazygit.tar.gz lazygit rm -rf lazygit.tar.gz lazygit
{{ end -}} {{ end -}}
{{ end }} {{ end }} {{/* if or (eq .chezmoi.osRelease.id "debian") (eq .chezmoi.osRelease.id "ubuntu") */}}
{{/* ==== Arch Linux / Manjaro ========================================== */ -}} {{/* ==== Arch Linux / Manjaro ========================================== */ -}}
{{ if or (eq .chezmoi.osRelease.id "manjaro") (eq .chezmoi.osRelease.id "arch") -}} {{ if or (eq .chezmoi.osRelease.id "manjaro") (eq .chezmoi.osRelease.id "arch") -}}
@ -194,6 +200,8 @@ if [[ ${#to_install_aur[@]} -gt 0 ]]; then
echo " - Installing missing AUR packages via yay: ${to_install_aur[@]}" echo " - Installing missing AUR packages via yay: ${to_install_aur[@]}"
yay -S --noconfirm "${to_install_aur[@]}" yay -S --noconfirm "${to_install_aur[@]}"
fi fi
{{ end -}} {{ end -}} {{/* if or (eq .chezmoi.osRelease.id "manjaro") (eq .chezmoi.osRelease.id "arch") */}}
{{ end -}} {{ end -}} {{/* else .unRootMode */}}
{{ end -}} {{/* if eq .chezmoi.os "linux" */}}