install.fairie/dotfiles/.local/share/chezmoi/home/.chezmoi.yaml.tmpl

136 lines
5.5 KiB
Cheetah

{{- $name := "Megabyte Labs" -}}
{{- $email := "noreply@megabyte.space" -}}
{{- $restricted := false -}}
{{- $work := false -}}
{{- $gmailAddress := "noreply@gmail.com" }}
{{- $gmailAddressAppPassword := "" }}
{{- $domain := "megabyte.space" }}
{{- $githubToken := "" }}
{{- $gitlabToken := "" }}
{{- $ngrokAuthToken := "" }}
{{- $slackApiToken := "" }}
{{- $tabbySyncToken := "" }}
{{- $toolchains := list "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")) -}}
{{- $headless := false -}}
{{- $ephemeral := false -}}
{{/* detect GitHub codespaces, VSCode remote containers, Docker containers, Multipass VMs, and Vagrant boxes */}}
{{- $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 -}}
{{- $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 Name" $name -}}
{{- $email = promptStringOnce $data.user "email" "Your Email" $email -}}
{{- 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 }}
{{- $domain = promptStringOnce $data.user "domain" "Domain" $domain -}}
{{- $gmailAddress = promptStringOnce $data.user "gmailAddress" "G-mail address" $gmailAddress -}}
{{- $gmailAddressAppPassword = promptStringOnce $data.user "gmailAddressAppPassword" "G-mail app password" $gmailAddressAppPassword -}}
{{- $ngrokAuthToken = promptStringOnce $data.user "ngrokAuthToken" "Ngrok authentication token" $ngrokAuthToken -}}
{{- $slackApiToken = promptStringOnce $data.user "slackApiToken" "Slack API token" $slackApiToken -}}
{{- $tabbySyncToken = promptStringOnce $data.user "tabbySyncToken" "Tabby Sync Token" $tabbySyncToken -}}
{{- else -}}
{{- $headless = true -}}
{{- writeToStdout "Chezmoi is running in headless environment.\n" -}}
{{- end -}}
{{- if not $headless -}}
age:
identity: "{{ .chezmoi.homeDir }}/.config/age/key.txt"
recipient: "age16kxd4ljclq9ksnxvl2ee7a5xnj744kwyv04p04ka0n3rzxdpl5nsq52svl"
{{- end }}
data:
host:
arch: "{{ .chezmoi.arch }}"
distro:
family: "{{ .chezmoi.os }}"
id: "{{ get .chezmoi.osRelease "id" | default .chezmoi.os }}"
home: "{{ .chezmoi.homeDir }}"
type: "{{ $chassisType }}"
work: {{ $work }}
restricted: {{ $restricted }}
headless: {{ $headless }}
toolchains:
{{- range $toolchain, $enabled := $toolchainsEnabled }}
{{ $toolchain}}: {{ $enabled }}
{{- end }}
user:
email: "{{ $email }}"
name: "{{ $name }}"
domain: "{{ $domain }}"
gmailAddress: "{{ $gmailAddress }}"
gmailAddressAppPassword: "{{ $gmailAddressAppPassword }}"
GITHUB_TOKEN: "{{ $githubToken }}"
GITLAB_TOKEN: "{{ $gitlabToken }}"
NGROK_AUTH_TOKEN: "{{ $ngrokAuthToken }}"
SLACK_API_TOKEN: "{{ $slackApiToken }}"
TABBY_SYNC_TOKEN: "{{ $tabbySyncToken }}"
diff:
format: "git"
pager: "delta"
git:
autoCommit: true
autoPush: true
textconv:
- pattern: "**/*.plist"
command: "plutil"
args:
- "-convert"
- "xml1"
- "-o"
- "-"
- "-"