diff --git a/.chezmoi.toml.tmpl b/.chezmoi.toml.tmpl index bb0c08c..bed3796 100644 --- a/.chezmoi.toml.tmpl +++ b/.chezmoi.toml.tmpl @@ -1,7 +1,6 @@ # This .chezmoi.toml file is used once only # It collects information about the system in order to determine # which of the _home.* dirs will be set as the .chezmoiroot -# {{- $githubToken := promptStringOnce . "githubToken" "Public GITHUB token (mostly for rate limits - !insecure!)" (or ( env "CZ_GITHUB_ACCESS_TOKEN" @@ -9,7 +8,7 @@ ) ( env "GITHUB_ACCESS_TOKEN" ) ( env "GITHUB_TOKEN" )) -}} -{{- $scriptTempDir := "~/.cache/chezmoi/tmp" }} +{{- $scriptTempDir := or (env "CZ_SCRIPT_TEMPDIR") "~/.cache/chezmoi/tmp" }} {{- $chassisType := "desktop" }} {{- $sysType := "posix" }} @@ -32,8 +31,9 @@ {{- $sysType = "windows" }} {{- $sysVendor = "pc" }} {{- $chassisType = (output "powershell.exe" "-NoProfile" "-NonInteractive" "-Command" "if ((Get-CimInstance -Class Win32_Battery | Measure-Object).Count -gt 0) { Write-Output 'laptop' } else { Write-Output 'desktop' }") | trim }} -{{- end }} +{{- end -}} +# scriptTempDir={{- $scriptTempDir | quote }} [scriptEnv] diff --git a/.init.me.sh b/.init.me.sh index e1505e2..1061953 100755 --- a/.init.me.sh +++ b/.init.me.sh @@ -34,6 +34,28 @@ done set -e ${SET_X:-:} -x +# Make sure temporary directory exists +CZ_SCRIPT_TEMPDIR="${CZ_SCRIPT_TEMPDIR:-~/.cache/chezmoi/tmp}" +mkdir -p "${CZ_SCRIPT_TEMPDIR}" + +# (in debug x2 mode) Show the existing configuration before destroying it +[[ -z "${CZ_DEBUG}" ]] || chezmoi cat-config + +# Destroy existing chezmoi state rm -fR ~/.config/chezmoi ~/.local/share/chezmoi/.chezmoiroot + +# Create a temporary chezmoi configuration bypass /tmp noexec situation +mkdir -p ~/.config/chezmoi +cat - > ~/.config/chezmoi/chezmoi.toml <