From d62459930eb42ae57f1afb95be0384e45780f98c Mon Sep 17 00:00:00 2001 From: Yuan Chiu Date: Sun, 4 May 2025 15:58:37 +0800 Subject: [PATCH] =?UTF-8?q?chezmoi=20=E5=BB=BA=E7=AB=8BunRoot=E5=9F=B7?= =?UTF-8?q?=E8=A1=8C=E6=A1=86=E6=9E=B6=EF=BC=88=E5=9F=B7=E8=A1=8C=E5=85=A7?= =?UTF-8?q?=E5=AE=B9=E5=B0=9A=E6=9C=AA=E5=AF=A6=E5=81=9A=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .chezmoi.toml.tmpl | 11 +++++++++-- ...change_before_darwin-install-packages.sh.tmpl | 2 +- ...nchange_before_linux-install-packages.sh.tmpl | 16 ++++++++++++---- 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/.chezmoi.toml.tmpl b/.chezmoi.toml.tmpl index db183e9..212c9d4 100644 --- a/.chezmoi.toml.tmpl +++ b/.chezmoi.toml.tmpl @@ -1,21 +1,27 @@ {{- $name := promptStringOnce . "name" "請輸入您的姓名" -}} {{- $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 -}} {{- $isServer := true -}} +{{- $unRootMode := true -}} {{- $enableSixel := false -}} {{- $enableGUI := false -}} {{- $enableYcm := false -}} -{{- if eq $hosttype "desktop" -}} +{{- if eq $hosttype "server" -}} +{{- $unRootMode = false -}} + +{{- else if eq $hosttype "desktop" -}} {{- $isServer = false -}} +{{- $unRootMode = false -}} {{- $enableSixel = true -}} {{- $enableGUI = true -}} {{- $enableYcm = true -}} {{- else if eq $hosttype "manual" -}} {{- $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" -}} {{- $enableGUI = promptBool "Does this machine have a GUI" -}} {{- $enableYcm = promptBool "Is enable Vim YCM compatible (Will use 2.7GB)" -}} @@ -27,6 +33,7 @@ sourceDir = "~/.local/share/chezmoi" name = {{ $name | quote }} email = {{ $email | quote }} serverStyle = {{ $isServer }} + unRootMode = {{ $unRootMode }} enableSixel = {{ $enableSixel }} {{/* TODO: packages.toml還沒處理 */}} noGUI = {{ not $enableGUI }} enableYcm = {{ $enableYcm }} diff --git a/.chezmoiscripts/run_onchange_before_darwin-install-packages.sh.tmpl b/.chezmoiscripts/run_onchange_before_darwin-install-packages.sh.tmpl index 4a3dff6..38ebd09 100644 --- a/.chezmoiscripts/run_onchange_before_darwin-install-packages.sh.tmpl +++ b/.chezmoiscripts/run_onchange_before_darwin-install-packages.sh.tmpl @@ -1,4 +1,4 @@ -{{ if eq .chezmoi.os "darwin" -}} +{{ if and (not .unRootMode) (eq .chezmoi.os "darwin") -}} #!/bin/sh # Install Homebrew diff --git a/.chezmoiscripts/run_onchange_before_linux-install-packages.sh.tmpl b/.chezmoiscripts/run_onchange_before_linux-install-packages.sh.tmpl index dc19f12..c2e8d15 100644 --- a/.chezmoiscripts/run_onchange_before_linux-install-packages.sh.tmpl +++ b/.chezmoiscripts/run_onchange_before_linux-install-packages.sh.tmpl @@ -1,5 +1,11 @@ {{ if eq .chezmoi.os "linux" -}} -{{/* ---- 安裝腳本 ------------------------------------------------------- */ -}} + +{{/* **** unRoot Mode *************************************************** */ -}} +{{ if .unRootMode -}} + + +{{/* **** Root Mode ***************************************************** */ -}} +{{ else -}} #!/bin/bash {{/* ==== Debian ======================================================== */ -}} @@ -57,7 +63,7 @@ fi rm -rf lazygit.tar.gz lazygit {{ end -}} -{{ end }} +{{ end }} {{/* if or (eq .chezmoi.osRelease.id "debian") (eq .chezmoi.osRelease.id "ubuntu") */}} {{/* ==== Arch Linux / Manjaro ========================================== */ -}} {{ 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[@]}" yay -S --noconfirm "${to_install_aur[@]}" 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" */}}