install.fairie/dotfiles/.local/share/chezmoi/.chezmoi.toml.tmpl

116 lines
4.8 KiB
Cheetah
Raw Normal View History

{{- $headless := false -}}
{{- $ephemeral := false -}}
{{- $restricted := false -}}
{{- $work := false -}}
{{- $ephemeralEnvOrUsername := or (env "CODESPACES") (env "REMOTE_CONTAINERS_IPC") (eq .chezmoi.username "root" "ubuntu" "vagrant" "vscode" "devcontainer") -}}
{{- $ephemeralCgroup := and (stat "/proc/1/cgroup") (output "cat" "/proc/1/cgroup" | regexMatch "(docker|lxc)") -}}
{{- if or $ephemeralEnvOrUsername $ephemeralCgroup -}}
{{- $headless = true -}}
{{- $ephemeral = true -}}
{{- writeToStdout "Chezmoi is running in a container.\n" -}}
{{- end -}}
{{- $toolchains := list "cloud" "docker" "iac" "java" "kubernetes" "node" "python" "rust" "extra" }}
{{- $data := . }}
{{- $_ := set $data "host" (default (dict) (get $data "host")) -}}
{{- $_ := set $data "user" (default (dict) (get $data "user")) -}}
{{- $_ := set $data "toolchains" (default (dict) (get $data "toolchains")) -}}
{{- $distro := dict "family" .chezmoi.os "id" (get .chezmoi.osRelease "id" | default .chezmoi.os) -}}
{{- if or (eq $distro.id "arch") (eq $distro.id "archarm") -}}
{{- $_ := set $distro "id" "archlinux" -}}
{{- end -}}
{{- $chassisType := "desktop" }}
{{- if $ephemeral -}}
{{- $chassisType = "ephemeral" }}
{{- else if eq .chezmoi.os "linux" }}
{{- if (.chezmoi.kernel.osrelease | lower | contains "microsoft") -}}
{{- $chassisType = "wsl" }}
{{- else -}}
{{- $chassisType = (output "hostnamectl" "--json=short" | mustFromJson).Chassis }}
{{- end -}}
{{- else if eq .chezmoi.os "darwin" }}
{{- if contains "MacBook" (output "sysctl" "-n" "hw.model") }}
{{- $chassisType = "laptop" }}
{{- else }}
{{- $chassisType = "desktop" }}
{{- end }}
{{- else if eq .chezmoi.os "windows" }}
{{- $chassisType = (output "powershell.exe" "-noprofile" "-command" "if (Get-WmiObject -Class win32_battery -ComputerName localhost) { echo laptop } else { echo desktop }") }}
{{- end }}
{{- $toolchainsEnabled := dict }}
{{- range $toolchain := $toolchains }}
{{- $withoutToolchains := env "WITHOUT_TOOLCHAINS" -}}
{{- $withoutToolchain := env (list "WITHOUT" (upper $toolchain) | join "_") -}}
{{- $withToolchain := env (list "WITH" (upper $toolchain) | join "_") -}}
{{- if and (or $withoutToolchains $withoutToolchain) (not $withToolchain) -}}
{{- writeToStdout (list "Disabled" $toolchain "toolchain.\n" | join " ") -}}
{{- $_ := set $toolchainsEnabled $toolchain false }}
{{- else }}
{{- $_ := set $toolchainsEnabled $toolchain true }}
{{- end}}
{{- end }}
{{- if stdinIsATTY -}}
{{- $work = promptBoolOnce $data.host "work" "Work environment" $work -}}
{{- $restricted = promptBoolOnce $data.host "restricted" "Restricted Environment (no sudo access)" $restricted -}}
{{- $name = promptStringOnce $data.user "name" "Your full name" $name -}}
{{- $email = promptStringOnce $data.user "email" "Your primary e-mail" $email -}}
{{- $gmailAddress := promptStringOnce . "G-mail address" -}}
{{- $gmailAddressAppPassword := promptStringOnce . "G-mail app password" -}}
{{- $ngrokAuthToken := promptStringOnce . "Ngrok authentication token" -}}
{{- $slackApiToken := promptStringOnce . "Slack API token" -}}
{{- range $toolchain := $toolchains }}
{{- $enabled := promptBoolOnce $data.toolchains $toolchain (list "Enable" $toolchain "toolchain" | join " ") (get $toolchainsEnabled $toolchain) -}}
{{- if and (eq $toolchain "kubernetes") $enabled (not $toolchainsEnabled.docker) -}}
{{- $_ := set $toolchainsEnabled "docker" $enabled }}
{{- writeToStdout "Enabled Docker toolchain to support Kubernetes.\n" -}}
{{- end -}}
{{- $_ := set $toolchainsEnabled $toolchain $enabled }}
{{- end }}
{{- writeToStdout "💡 Tip: you can re-enter your name and email with `chezmoi init --data=false`.\n" -}}
{{- else -}}
{{- $headless = true -}}
{{- writeToStdout "Chezmoi is running in headless environment.\n" -}}
{{- end -}}
sourceDir = {{ .chezmoi.sourceDir | quote }}
[data]
work = {{ $work | quote }}
restricted = {{ $restricted | quote }}
codespaces = {{ $codespaces }}
headless = {{ $headless }}
{{- if $ephemeral }}
email = "help@megabyte.space"
gmailAddress = ""
gmailAddressAppPassword = ""
name = "Megabyte Labs"
{{- else }}
email = {{ $email | quote }}
gmailAddress = {{ $gmailAddress | quote }}
gmailAddressAppPassword = {{ $gmailAddressAppPassword | quote }}
name = {{ $name | quote }}
DOCKERHUB_TOKEN =
GITHUB_TOKEN = {{ $githubToken | quote }}
GITLAB_TOKEN = {{ $gitlabToken | quote }}
NGROK_AUTH_TOKEN = {{ $ngrokAuthToken | quote }}
SLACK_API_TOKEN = {{ $slackApiToken | quote }}
TABBY_SYNC_TOKEN = "196a3118cc7be31cd13d2862d7e33c122357fd9fa36c2f149e8b018b82c260ab6b72169f4c411a6bedd2b8b4124c3540daa57778f20a28cfe2c797776f9a616c"
VAGRANT_CLOUD_TOKEN =
{{- end }}
[diff]
format = "git"
pager = "delta"
[git]
autoCommit = true
autoPush = true