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

178 lines
8.2 KiB
Cheetah

{{- $name := "Megabyte Labs" -}}
{{- $email := "noreply@megabyte.space" -}}
{{- $restricted := false -}}
{{- $work := false -}}
{{- $gmailAddress := "noreply@gmail.com" -}}
{{- $gmailAddressAppPassword := "" -}}
{{- $domain := "megabyte.space" -}}
{{- $cloudflareUsername := "" -}}
{{- $cloudflareToken := "" -}}
{{- $cloudflareAccessKeyId := "" -}}
{{- $cloudflareSecretAccessKey := "" -}}
{{- $cloudflareR2AccountId := "" -}}
{{- $githubUsername := "ProfessorManhattan" -}}
{{- $githubReadToken := "" -}}
{{- $gitlabReadToken := "" -}}
{{- $locale := (output "echo" "$LANG") }}
{{- $ngrokAuthToken := "" -}}
{{- $slackApiToken := "" -}}
{{- $tabbySyncToken := "" -}}
{{- $timezone := "" -}}
{{- $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 }}
{{- $cpuCores := 1 }}
{{- $cpuThreads := 1 }}
{{- if eq .chezmoi.os "darwin" }}
{{- $cpuCores = (output "sysctl" "-n" "hw.physicalcpu_max") | trim | atoi }}
{{- $cpuThreads = (output "sysctl" "-n" "hw.logicalcpu_max") | trim | atoi }}
{{- else if eq .chezmoi.os "linux" }}
{{- $cpuCores = (output "sh" "-c" "lscpu --online --parse | grep --invert-match '^#' | sort --field-separator=',' --key='2,4' --unique | wc --lines") | trim | atoi }}
{{- $cpuThreads = (output "sh" "-c" "lscpu --online --parse | grep --invert-match '^#' | wc --lines") | trim | atoi }}
{{- else if eq .chezmoi.os "windows" }}
{{- $cpuCores = (output "powershell.exe" "-NoProfile" "-NonInteractive" "-Command" "(Get-CimInstance -ClassName 'Win32_Processor').NumberOfCores") | trim | atoi }}
{{- $cpuThreads = (output "powershell.exe" "-NoProfile" "-NonInteractive" "-Command" "(Get-CimInstance -ClassName 'Win32_Processor').NumberOfLogicalProcessors") | trim | atoi }}
{{- 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 -}}
{{- $timezone = promptStringOnce $data.user "timezone" "Timezone" $timezone -}}
{{- $cloudflareUsername = promptStringOnce $data.user "cloudflareUsername" "CloudFlare E-Mail" $email -}}
{{- $cloudflareToken = promptStringOnce $data.user "cloudflareToken" "CloudFlare API Token" $cloudflareToken -}}
{{- $gitlabReadToken = promptStringOnce $data.user "gitlabReadToken" "GitLab read-only token (See: https://github.com/gabrie30/ghorg#scm-provider-setup)" $gitlabReadToken }}
{{- $githubReadToken = promptStringOnce $data.user "githubReadToken" "GitHub read-only token (See: https://github.com/gabrie30/ghorg#scm-provider-setup)" $githubReadToken }}
{{- $githubUsername = promptStringOnce $data.user "githubUsername" "GitHub username" $githubUsername -}}
{{- $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 }}"
cpu:
cores: "{{ $cpuCores }}"
threads: "{{ $cpuThreads }}"
distro:
family: "{{ .chezmoi.os }}"
id: "{{ get .chezmoi.osRelease "id" | default .chezmoi.os }}"
home: "{{ .chezmoi.homeDir }}"
homeParentFolder: "{{ if eq .chezmoi.os "linux" }}/home{{ else if eq .chezmoi.os "darwin" }}/Users{{ else }}C:\Users{{ end }}"
type: "{{ $chassisType }}"
work: {{ $work }}
restricted: {{ $restricted }}
headless: {{ $headless }}
toolchains:
{{- range $toolchain, $enabled := $toolchainsEnabled }}
{{ $toolchain}}: {{ $enabled }}
{{- end }}
user:
email: "{{ $email }}"
name: "{{ $name }}"
username: "{{ output "echo" "$USER" }}
domain: "{{ $domain }}"
gmailAddress: "{{ $gmailAddress }}"
gmailAddressAppPassword: "{{ $gmailAddressAppPassword }}"
githubUsername: "{{ $githubUsername }}"
locale: "{{ $locale }}"
timezone: "{{ $timezone }}"
CLOUDFLARE_USERNAME: "{{ $cloudflareUsername }}"
CLOUDFLARE_ACCESS_KEY_ID: "{{ $cloudflareAccessKeyId }}"
CLOUDFLARE_SECRET_ACCESS_KEY: "{{ $cloudflareSecretAccessKey }}"
CLOUDFLARE_R2_ACCOUNT_ID: "{{ $cloudflareR2AccountId }}"
GITHUB_READ_TOKEN: "{{ $githubReadToken }}"
GITLAB_READ_TOKEN: "{{ $gitlabReadToken }}"
NGROK_AUTH_TOKEN: "{{ $ngrokAuthToken }}"
SLACK_API_TOKEN: "{{ $slackApiToken }}"
TABBY_SYNC_TOKEN: "{{ $tabbySyncToken }}"
diff:
format: "git"
pager: "delta"
git:
autoCommit: true
autoPush: true
scriptEnv:
LEXICON_CLOUDFLARE_USERNAME: "{{ $cloudflareUsername }}"
LEXICON_CLOUDFLARE_TOKEN: "{{ $cloudflareToken }}"
textconv:
- pattern: "**/*.plist"
command: "plutil"
args:
- "-convert"
- "xml1"
- "-o"
- "-"
- "-"